-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
107 lines (92 loc) · 3.39 KB
/
Copy pathsetup.py
File metadata and controls
107 lines (92 loc) · 3.39 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
#!/usr/bin/env python3
"""
Setup script for Person Detection Challenge
Run this to verify your environment is ready
"""
import sys
import subprocess
import importlib
import platform
def check_python_version():
"""Check if Python version is compatible."""
version = sys.version_info
if version.major == 3 and version.minor >= 8:
print(f"✅ Python {version.major}.{version.minor}.{version.micro} - Compatible")
return True
else:
print(f"❌ Python {version.major}.{version.minor}.{version.micro} - Need Python 3.8+")
return False
def check_package(package_name, import_name=None):
"""Check if a package is installed and importable."""
if import_name is None:
import_name = package_name
try:
module = importlib.import_module(import_name)
version = getattr(module, '__version__', 'unknown')
print(f"✅ {package_name} ({version})")
return True
except ImportError:
print(f"❌ {package_name} - Not installed")
return False
def install_requirements():
"""Install requirements from requirements.txt."""
try:
print("📦 Installing requirements...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("✅ Requirements installed successfully")
return True
except subprocess.CalledProcessError:
print("❌ Failed to install requirements")
return False
def run_test():
"""Run the test script."""
try:
print("🧪 Running test script...")
subprocess.check_call([sys.executable, "test_app.py"])
return True
except subprocess.CalledProcessError:
print("❌ Test script failed")
return False
def main():
"""Main setup and verification."""
print("🎯 Person Detection Challenge Setup")
print("=" * 40)
print(f"🖥️ Platform: {platform.system()} {platform.release()}")
# Check Python version
if not check_python_version():
print("\n❌ Setup failed: Incompatible Python version")
sys.exit(1)
print("\n📋 Checking existing packages...")
packages = [
("opencv-python", "cv2"),
("ultralytics", "ultralytics"),
("supervision", "supervision"),
("numpy", "numpy"),
("Pillow", "PIL")
]
missing_packages = []
for pkg_name, import_name in packages:
if not check_package(pkg_name, import_name):
missing_packages.append(pkg_name)
if missing_packages:
print(f"\n📦 Missing packages: {', '.join(missing_packages)}")
response = input("Install missing packages? (y/n): ").lower().strip()
if response == 'y':
if not install_requirements():
print("\n❌ Setup failed: Could not install requirements")
sys.exit(1)
else:
print("\n⚠️ Setup incomplete: Missing packages")
sys.exit(1)
print("\n🧪 Running verification test...")
if run_test():
print("\n🎉 CHALLENGE SETUP COMPLETE!")
print("\n🚀 You're ready to start the challenge:")
print(" python person_detector.py --source 0")
print(" python gui_app.py")
else:
print("\n❌ Setup verification failed")
print("Check the error messages above and try again")
sys.exit(1)
if __name__ == "__main__":
main()