Spaces:
Sleeping
Sleeping
Replace Provider to Novita
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import subprocess
|
|
4 |
import sys
|
5 |
import os
|
6 |
|
7 |
-
def ensure_mmpose_installed(local_path='/data/
|
8 |
"""
|
9 |
Check if 'mmpose' can be imported; if not, attempt to install it from local_path.
|
10 |
local_path should contain setup.py or pyproject.toml so that pip can install it.
|
@@ -22,28 +22,28 @@ def ensure_mmpose_installed(local_path='/data/WHAM/third-party/ViTPose'):
|
|
22 |
else:
|
23 |
print(f"'{package_name}' not found, attempting installation...")
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
ensure_mmpose_installed('/data/
|
47 |
|
48 |
|
49 |
|
@@ -92,7 +92,7 @@ class PoseEstimationApp:
|
|
92 |
if not token:
|
93 |
raise RuntimeError("HF_TOKEN environment variable not set, please set the access token in deployment environment.")
|
94 |
try:
|
95 |
-
self.client = InferenceClient(model=model_name, token=token)
|
96 |
except Exception as e:
|
97 |
raise RuntimeError(f"Failed to initialize remote inference client: {e}")
|
98 |
|
|
|
4 |
import sys
|
5 |
import os
|
6 |
|
7 |
+
def ensure_mmpose_installed(local_path='/data/wheelhouse/mmpose-0.24.0-py2.py3-none-any.whl'):
|
8 |
"""
|
9 |
Check if 'mmpose' can be imported; if not, attempt to install it from local_path.
|
10 |
local_path should contain setup.py or pyproject.toml so that pip can install it.
|
|
|
22 |
else:
|
23 |
print(f"'{package_name}' not found, attempting installation...")
|
24 |
|
25 |
+
# If we reach here, we need to install or reinstall
|
26 |
+
# Check that the directory exists
|
27 |
+
if not os.path.isdir(local_path):
|
28 |
+
raise FileNotFoundError(f"Specified install directory does not exist: {local_path}")
|
29 |
|
30 |
+
# Construct pip install command using the current Python executable
|
31 |
+
cmd = [sys.executable, "-m", "pip", "install", local_path]
|
32 |
+
print("Running command:", " ".join(cmd))
|
33 |
+
try:
|
34 |
+
subprocess.check_call(cmd)
|
35 |
+
except subprocess.CalledProcessError as e:
|
36 |
+
raise RuntimeError(f"Failed to install mmpose: {e}")
|
37 |
|
38 |
+
# After installation, try importing again
|
39 |
+
try:
|
40 |
+
module = importlib.import_module(package_name)
|
41 |
+
print(f"'{package_name}' installed and imported successfully, version: {getattr(module, '__version__', 'unknown')}")
|
42 |
+
return True
|
43 |
+
except Exception as e:
|
44 |
+
raise RuntimeError(f"Installed but still cannot import '{package_name}': {e}")
|
45 |
|
46 |
+
ensure_mmpose_installed('/data/wheelhouse/mmpose-0.24.0-py2.py3-none-any.whl')
|
47 |
|
48 |
|
49 |
|
|
|
92 |
if not token:
|
93 |
raise RuntimeError("HF_TOKEN environment variable not set, please set the access token in deployment environment.")
|
94 |
try:
|
95 |
+
self.client = InferenceClient(model=model_name, token=token, provider="novita")
|
96 |
except Exception as e:
|
97 |
raise RuntimeError(f"Failed to initialize remote inference client: {e}")
|
98 |
|