Update model.py
Browse files
model.py
CHANGED
@@ -7,22 +7,38 @@ import subprocess
|
|
7 |
import sys
|
8 |
import json
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
import huggingface_hub
|
28 |
import numpy as np
|
|
|
7 |
import sys
|
8 |
import json
|
9 |
|
10 |
+
def run_command(command):
|
11 |
+
try:
|
12 |
+
subprocess.run(shlex.split(command), check=True, capture_output=True, text=True)
|
13 |
+
except subprocess.CalledProcessError as e:
|
14 |
+
print(f"Error running command '{command}':")
|
15 |
+
print(f"Exit code: {e.returncode}")
|
16 |
+
print(f"stdout: {e.stdout}")
|
17 |
+
print(f"stderr: {e.stderr}")
|
18 |
+
raise
|
19 |
|
20 |
+
if os.getenv("SYSTEM") == "spaces":
|
21 |
+
try:
|
22 |
+
# Update pip first
|
23 |
+
run_command("pip install --upgrade pip")
|
24 |
+
|
25 |
+
# Install openmim version 0.3.9
|
26 |
+
run_command("pip install openmim==0.3.9")
|
27 |
+
|
28 |
+
# Install specific version of click
|
29 |
+
run_command("pip install click==8.0.4")
|
30 |
+
|
31 |
+
from mmcv.utils import install_module, uninstall_module
|
32 |
+
|
33 |
+
uninstall_module("mmcv-full")
|
34 |
+
install_module("mmcv-full==1.5.0")
|
35 |
+
|
36 |
+
run_command("pip uninstall -y opencv-python")
|
37 |
+
run_command("pip uninstall -y opencv-python-headless")
|
38 |
+
run_command("pip install opencv-python-headless==4.5.5.64")
|
39 |
+
except Exception as e:
|
40 |
+
print(f"An error occurred during setup: {str(e)}")
|
41 |
+
sys.exit(1)
|
42 |
|
43 |
import huggingface_hub
|
44 |
import numpy as np
|