-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathverify_setup.py
More file actions
189 lines (160 loc) Β· 5.38 KB
/
verify_setup.py
File metadata and controls
189 lines (160 loc) Β· 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/env python3
"""
Verification script to test if the setup is working correctly
"""
import os
import sys
import importlib
def check_python_version():
"""Check Python version"""
print("π Checking Python version...")
version = sys.version_info
if version.major >= 3 and version.minor >= 8:
print(f"β
Python {version.major}.{version.minor}.{version.micro} - OK")
return True
else:
print(f"β Python {version.major}.{version.minor}.{version.micro} - Need Python 3.8+")
return False
def check_dependencies():
"""Check if all required dependencies are installed"""
print("\nπ¦ Checking dependencies...")
required_packages = [
'tensorflow',
'numpy',
'pandas',
'matplotlib',
'seaborn',
'sklearn',
'cv2',
'PIL',
'tqdm'
]
missing = []
for package in required_packages:
try:
importlib.import_module(package)
print(f"β
{package}")
except ImportError:
print(f"β {package} - MISSING")
missing.append(package)
if missing:
print(f"\nβ Missing packages: {', '.join(missing)}")
print("Run: pip install -r requirements.txt")
return False
print("β
All dependencies installed")
return True
def check_gpu():
"""Check GPU availability"""
print("\nπ₯οΈ Checking GPU availability...")
try:
import tensorflow as tf
gpus = tf.config.list_physical_devices('GPU')
if gpus:
print(f"β
GPU detected: {len(gpus)} device(s)")
for gpu in gpus:
print(f" - {gpu.name}")
return True
else:
print("β οΈ No GPU detected - training will be slower on CPU")
return True
except Exception as e:
print(f"β Error checking GPU: {e}")
return False
def check_directories():
"""Check if necessary directories exist"""
print("\nπ Checking directories...")
required_dirs = ['post_processing', 'results', 'models']
missing = []
for dir_name in required_dirs:
if os.path.exists(dir_name):
print(f"β
{dir_name}/")
else:
print(f"β {dir_name}/ - MISSING")
missing.append(dir_name)
if missing:
print(f"\nCreating missing directories...")
for dir_name in missing:
os.makedirs(dir_name, exist_ok=True)
print(f"β
Created {dir_name}/")
return True
def check_config():
"""Check configuration files"""
print("\nβοΈ Checking configuration...")
config_files = ['train_siamese.py', 'config_siamese.py', 'run_training.py']
missing = []
for file_name in config_files:
if os.path.exists(file_name):
print(f"β
{file_name}")
else:
print(f"β {file_name} - MISSING")
missing.append(file_name)
if missing:
print(f"β Missing configuration files: {', '.join(missing)}")
return False
# Check debug mode setting
try:
with open('train_siamese.py', 'r') as f:
content = f.read()
if 'DEBUG_MODE = True' in content:
print("β οΈ DEBUG_MODE is True (for local testing)")
elif 'DEBUG_MODE = False' in content:
print("β
DEBUG_MODE is False (for production)")
else:
print("β οΈ DEBUG_MODE setting not found")
except Exception as e:
print(f"β Error reading train_siamese.py: {e}")
return False
return True
def test_tensorflow():
"""Test TensorFlow functionality"""
print("\nπ§ͺ Testing TensorFlow...")
try:
import tensorflow as tf
import numpy as np
# Test basic operations
a = tf.constant([1, 2, 3])
b = tf.constant([4, 5, 6])
c = a + b
print(f"β
TensorFlow basic operations: {c.numpy()}")
# Test model creation
model = tf.keras.Sequential([
tf.keras.layers.Dense(10, input_shape=(5,)),
tf.keras.layers.Dense(1)
])
print("β
TensorFlow model creation")
return True
except Exception as e:
print(f"β TensorFlow test failed: {e}")
return False
def main():
"""Main verification function"""
print("π Cat Re-identification System Setup Verification")
print("=" * 50)
checks = [
check_python_version,
check_dependencies,
check_gpu,
check_directories,
check_config,
test_tensorflow
]
all_passed = True
for check in checks:
if not check():
all_passed = False
print("\n" + "=" * 50)
if all_passed:
print("π All checks passed! Your setup is ready for training.")
print("\nπ Next steps:")
print("1. Download your dataset to post_processing/ directory")
print("2. Run: python run_training.py")
print("3. Monitor training progress")
else:
print("β Some checks failed. Please fix the issues above.")
print("\nπ§ Common fixes:")
print("- Run: pip install -r requirements.txt")
print("- Check your Python version (need 3.8+)")
print("- Verify your dataset is in post_processing/")
return all_passed
if __name__ == "__main__":
main()