Spaces:
Paused
Paused
Fix launch-timeout crash; download weights from model repo
Browse filesRoot cause: ultralytics installed with no torch pin pulled full CUDA
wheels on cpu-basic hardware, slowing the build past the 30-minute
health-check window. Pin CPU-only torch/torchvision and a stable
ultralytics version, redirect framework caches to /tmp, and load the
model from the FathomNet/trash-detector model repo via
huggingface_hub instead of bundling the 130MB weight file in the
Space repo. Bump gradio to 6.9.0.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- README.md +1 -1
- app.py +16 -2
- requirements.txt +5 -1
- trash_mbari_09072023_640imgsz_50epochs_yolov8.pt +0 -3
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🗑️
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: cc-by-4.0
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.9.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: cc-by-4.0
|
app.py
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import glob
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
from ultralytics import YOLO
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
PREDICT_KWARGS = {
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
# Keep framework caches on ephemeral scratch space rather than the Space's
|
| 4 |
+
# persistent disk, to avoid exceeding the storage quota:
|
| 5 |
+
# https://discuss.huggingface.co/t/how-to-fix-workload-evicted-storage-limit-exceeded-50g-error-in-huggingface-spaces/169258
|
| 6 |
+
os.environ.setdefault("TORCH_HOME", "/tmp/torch_cache")
|
| 7 |
+
os.environ.setdefault("HUB_DIR", "/tmp/torch_hub")
|
| 8 |
+
os.environ.setdefault("HF_HOME", "/tmp/hf_home")
|
| 9 |
+
os.environ.setdefault("TMPDIR", "/tmp")
|
| 10 |
+
|
| 11 |
import glob
|
| 12 |
import gradio as gr
|
| 13 |
+
from huggingface_hub import hf_hub_download
|
| 14 |
from ultralytics import YOLO
|
| 15 |
|
| 16 |
+
MODEL_PATH = hf_hub_download(
|
| 17 |
+
repo_id="FathomNet/trash-detector",
|
| 18 |
+
filename="trash_mbari_09072023_640imgsz_50epochs_yolov8.pt",
|
| 19 |
+
)
|
| 20 |
+
model = YOLO(MODEL_PATH)
|
| 21 |
|
| 22 |
|
| 23 |
PREDICT_KWARGS = {
|
requirements.txt
CHANGED
|
@@ -1 +1,5 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
+
torch==2.14.0
|
| 3 |
+
torchvision==0.29.0
|
| 4 |
+
ultralytics==8.3.108
|
| 5 |
+
huggingface_hub
|
trash_mbari_09072023_640imgsz_50epochs_yolov8.pt
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:deebcced65ec08042d982522dd5326b0137b0b7935bf41ed51a10e714d54226e
|
| 3 |
-
size 136708926
|
|
|
|
|
|
|
|
|
|
|
|