Spaces:
Sleeping
Sleeping
Fix Spaces launch and lazy load YOLO
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ from pathlib import Path
|
|
| 9 |
import cv2
|
| 10 |
import gradio as gr
|
| 11 |
import numpy as np
|
| 12 |
-
from ultralytics import YOLO
|
| 13 |
|
| 14 |
|
| 15 |
MODEL_PATH = Path("Weight/yolo11x-pose.pt")
|
|
@@ -62,9 +61,11 @@ TEXT_COLOR = (230, 240, 255)
|
|
| 62 |
|
| 63 |
|
| 64 |
@lru_cache(maxsize=1)
|
| 65 |
-
def load_model()
|
| 66 |
if not MODEL_PATH.exists():
|
| 67 |
raise FileNotFoundError(f"Missing YOLO model: {MODEL_PATH}")
|
|
|
|
|
|
|
| 68 |
return YOLO(str(MODEL_PATH))
|
| 69 |
|
| 70 |
|
|
@@ -267,8 +268,13 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", neutral_hue="slate"), ti
|
|
| 267 |
],
|
| 268 |
outputs=[video_output, file_output, summary_output],
|
| 269 |
show_progress="full",
|
|
|
|
| 270 |
)
|
| 271 |
|
| 272 |
|
| 273 |
if __name__ == "__main__":
|
| 274 |
-
demo.queue(default_concurrency_limit=1).launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
import cv2
|
| 10 |
import gradio as gr
|
| 11 |
import numpy as np
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
MODEL_PATH = Path("Weight/yolo11x-pose.pt")
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
@lru_cache(maxsize=1)
|
| 64 |
+
def load_model():
|
| 65 |
if not MODEL_PATH.exists():
|
| 66 |
raise FileNotFoundError(f"Missing YOLO model: {MODEL_PATH}")
|
| 67 |
+
from ultralytics import YOLO
|
| 68 |
+
|
| 69 |
return YOLO(str(MODEL_PATH))
|
| 70 |
|
| 71 |
|
|
|
|
| 268 |
],
|
| 269 |
outputs=[video_output, file_output, summary_output],
|
| 270 |
show_progress="full",
|
| 271 |
+
api_name=False,
|
| 272 |
)
|
| 273 |
|
| 274 |
|
| 275 |
if __name__ == "__main__":
|
| 276 |
+
demo.queue(default_concurrency_limit=1).launch(
|
| 277 |
+
server_name="0.0.0.0",
|
| 278 |
+
server_port=7860,
|
| 279 |
+
show_api=False,
|
| 280 |
+
)
|