-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_installation.py
More file actions
175 lines (134 loc) · 4.46 KB
/
Copy pathtest_installation.py
File metadata and controls
175 lines (134 loc) · 4.46 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
#!/usr/bin/env python3
"""
Test script to verify Image Interrogator installation.
"""
import sys
from pathlib import Path
# Add project to path
sys.path.insert(0, str(Path(__file__).parent))
def test_imports():
"""Test that all modules can be imported."""
print("Testing module imports...")
try:
from core import InterrogationDatabase, FileManager, hash_image_content
print(" ✓ Core modules")
except ImportError as e:
print(f" ✗ Core modules: {e}")
return False
try:
from interrogators import CLIPInterrogator, WDInterrogator
print(" ✓ Interrogators")
except ImportError as e:
print(f" ✗ Interrogators: {e}")
return False
try:
from ui import MainWindow
print(" ✓ UI components")
except ImportError as e:
print(f" ✗ UI components: {e}")
return False
return True
def test_dependencies():
"""Test that required packages are installed."""
print("\nTesting dependencies...")
packages = [
('PyQt6', 'PyQt6.QtWidgets'),
('Pillow', 'PIL'),
('NumPy', 'numpy'),
('ONNX Runtime', 'onnxruntime'),
('HuggingFace Hub', 'huggingface_hub'),
('Pandas', 'pandas'),
]
all_installed = True
for name, module in packages:
try:
__import__(module)
print(f" ✓ {name}")
except ImportError:
print(f" ✗ {name} - Not installed")
all_installed = False
# Optional dependencies
print("\nOptional dependencies:")
optional = [
('CLIP Interrogator', 'clip_interrogator'),
('PyTorch', 'torch'),
('TorchVision', 'torchvision'),
]
for name, module in optional:
try:
__import__(module)
print(f" ✓ {name}")
except ImportError:
print(f" ○ {name} - Not installed (optional)")
return all_installed
def test_database():
"""Test database creation."""
print("\nTesting database...")
try:
from core import InterrogationDatabase
db_path = Path(__file__).parent / "test_db.db"
db = InterrogationDatabase(str(db_path))
# Test basic operations
model_id = db.register_model("test_model", "TEST", version="1.0")
stats = db.get_statistics()
db.close()
# Cleanup
db_path.unlink()
print(" ✓ Database operations")
return True
except Exception as e:
print(f" ✗ Database operations: {e}")
return False
def test_gpu_availability():
"""Test GPU availability."""
print("\nChecking GPU availability...")
# CUDA for PyTorch
try:
import torch
if torch.cuda.is_available():
print(f" ✓ CUDA available: {torch.cuda.get_device_name(0)}")
else:
print(" ○ CUDA not available (CPU mode will be used)")
except ImportError:
print(" ○ PyTorch not installed")
# ONNX Runtime
try:
import onnxruntime as ort
providers = ort.get_available_providers()
if 'CUDAExecutionProvider' in providers:
print(" ✓ ONNX Runtime GPU support")
else:
print(" ○ ONNX Runtime CPU only")
except ImportError:
print(" ○ ONNX Runtime not installed")
def main():
"""Run all tests."""
print("=" * 60)
print("Image Interrogator - Installation Test")
print("=" * 60)
results = []
# Run tests
results.append(("Module Imports", test_imports()))
results.append(("Dependencies", test_dependencies()))
results.append(("Database", test_database()))
# GPU check (informational)
test_gpu_availability()
# Summary
print("\n" + "=" * 60)
print("Test Summary:")
print("=" * 60)
for name, passed in results:
status = "✓ PASSED" if passed else "✗ FAILED"
print(f"{name}: {status}")
all_passed = all(result[1] for result in results)
print("\n" + "=" * 60)
if all_passed:
print("All tests passed! Installation is complete.")
print("\nYou can now run: python main.py")
else:
print("Some tests failed. Please install missing dependencies:")
print(" pip install -r requirements.txt")
print("=" * 60)
return 0 if all_passed else 1
if __name__ == '__main__':
sys.exit(main())