Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,16 +10,26 @@ from flask_cors import CORS
|
|
10 |
import os
|
11 |
import shutil
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
15 |
CUSTOM_MODEL_PATH = "/app/models/pose_landmark_heavy.tflite"
|
16 |
-
DEFAULT_MODEL_PATH = "/usr/local/lib/python3.10/site-packages/mediapipe/modules/pose_landmark/pose_landmark_heavy.tflite"
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
app = Flask(__name__)
|
24 |
CORS(app)
|
25 |
|
|
|
10 |
import os
|
11 |
import shutil
|
12 |
|
13 |
+
# --- Monkey Patch: Override model path before using mediapipe.pose ---
|
14 |
+
from mediapipe.python.solutions import pose as mp_pose_module
|
15 |
+
|
16 |
CUSTOM_MODEL_PATH = "/app/models/pose_landmark_heavy.tflite"
|
|
|
17 |
|
18 |
+
def monkey_patch_pose_path(model_complexity):
|
19 |
+
model_complexity_map = {
|
20 |
+
0: "pose_landmark_lite",
|
21 |
+
1: "pose_landmark_full",
|
22 |
+
2: "pose_landmark_heavy"
|
23 |
+
}
|
24 |
+
if model_complexity in model_complexity_map:
|
25 |
+
file_name = model_complexity_map[model_complexity] + ".tflite"
|
26 |
+
mp_pose_module.MODEL_PATHS[model_complexity] = CUSTOM_MODEL_PATH
|
27 |
+
else:
|
28 |
+
raise ValueError(f"Unsupported model complexity: {model_complexity}")
|
29 |
+
|
30 |
+
# Monkey patch before creating Pose instance
|
31 |
+
monkey_patch_pose_path(model_complexity=2)
|
32 |
+
|
33 |
app = Flask(__name__)
|
34 |
CORS(app)
|
35 |
|