Spaces:
Running
Running
File size: 1,821 Bytes
ab8cebe | 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 | import os
import subprocess
import sys
def main():
print("--- Vision.AI Standard Setup & Launch ---")
# 1. Detect environment
project_root = os.getcwd()
venv_python = os.path.join(project_root, "venv", "Scripts", "python.exe")
if os.path.exists(venv_python):
print(f"Detected Virtual Environment: {venv_python}")
python_exe = venv_python
else:
print("Warning: No virtual environment detected. Using system Python.")
python_exe = sys.executable
# 2. Ensure basic requirements (checking if deepface exists first)
try:
subprocess.run([python_exe, "-c", "import deepface"], check=True, capture_output=True)
print("Required packages (deepface) already installed.")
except (subprocess.CalledProcessError, FileNotFoundError):
print("Installing dependencies from requirements.txt...")
# Note: We use --no-deps or specific install if global pip is broken,
# but here we just try standard install first
subprocess.run([python_exe, "-m", "pip", "install", "-r", "requirements.txt"])
# 3. Check for weights
print("\nChecking for ML weights...")
scripts_dir = os.path.join(project_root, "scripts")
download_script = os.path.join(scripts_dir, "download_weights.py")
if os.path.exists(download_script):
subprocess.run([python_exe, download_script])
else:
print(f"[ERROR] Found no download script at {download_script}")
# 4. Launch the app
print("\nLaunching Vision.AI Dashboard...")
print("Point your browser to http://127.0.0.1:5000")
print("Press CTRL+C to stop.")
try:
subprocess.run([python_exe, "run.py"])
except KeyboardInterrupt:
print("\nStopping...")
if __name__ == "__main__":
main()
|