Spaces:
Running
Running
Modernize: pin CPU torch, download weights from model repo
Browse filesPreventive fix for the same failure mode hitting other spaces in this
org: unpinned ultralytics/torch pulls full CUDA wheels on cpu-basic
hardware. Pin CPU-only torch/torchvision and a stable ultralytics
version, redirect framework caches to /tmp, and load the model from
the FathomNet/megalodon-2023-yolov8 model repo via huggingface_hub
instead of bundling the weight file. Bump gradio to 6.9.0.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🦈
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: cc-by-4.0
|
|
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.9.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 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/megalodon-2023-yolov8",
|
| 18 |
+
filename="mbari-megalodon-yolov8x.pt",
|
| 19 |
+
)
|
| 20 |
+
model = YOLO(MODEL_PATH)
|
| 21 |
|
| 22 |
|
| 23 |
PREDICT_KWARGS = {
|
best.pt
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:24fe6d9808fdd44b64d2fbfc23bbe6455520eb7b392d3664c92cbcdf88a09196
|
| 3 |
-
size 136714110
|
|
|
|
|
|
|
|
|
|
|
|
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
|