Spaces:
Running on Zero
Running on Zero
Read beat_this's checkpoint from the Hub mirror, since the JKU server returns 503, and pin the weights' revisions.
Browse files
app.py
CHANGED
|
@@ -77,6 +77,7 @@ def _patched_info(filepath, *args, **kwargs):
|
|
| 77 |
|
| 78 |
torchaudio.info = _patched_info
|
| 79 |
|
|
|
|
| 80 |
import tempfile
|
| 81 |
import threading
|
| 82 |
from pathlib import Path
|
|
@@ -86,11 +87,18 @@ from pyharp import ModelCard, build_endpoint
|
|
| 86 |
from pyharp.tags import Subcategory
|
| 87 |
|
| 88 |
from inference import inference
|
| 89 |
-
from beat_this.inference import load_checkpoint as load_beat_checkpoint
|
| 90 |
|
| 91 |
-
# beat_this downloads its checkpoint on first use, which
|
| 92 |
-
# resolution
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
CHECKPOINT_REPO = "teamup-tech/FST-AI-Music-Detection-checkpoints"
|
| 96 |
CHECKPOINT_DIR = Path("checkpoints")
|
|
@@ -106,7 +114,8 @@ def download_checkpoints():
|
|
| 106 |
try:
|
| 107 |
CHECKPOINT_DIR.mkdir(exist_ok=True)
|
| 108 |
for filename in ("Stage-1.ckpt", "Stage-2.ckpt"):
|
| 109 |
-
hf_hub_download(repo_id=CHECKPOINT_REPO, filename=filename, local_dir=str(CHECKPOINT_DIR)
|
|
|
|
| 110 |
print("Checkpoints ready.")
|
| 111 |
except Exception as e:
|
| 112 |
checkpoint_error = str(e)
|
|
|
|
| 77 |
|
| 78 |
torchaudio.info = _patched_info
|
| 79 |
|
| 80 |
+
import contextlib
|
| 81 |
import tempfile
|
| 82 |
import threading
|
| 83 |
from pathlib import Path
|
|
|
|
| 87 |
from pyharp.tags import Subcategory
|
| 88 |
|
| 89 |
from inference import inference
|
|
|
|
| 90 |
|
| 91 |
+
# beat_this downloads its checkpoint from the JKU cloud on first use, which has failed both inside
|
| 92 |
+
# a GPU call (no name resolution) and at startup (503). The same file is mirrored on the Hub and
|
| 93 |
+
# linked where torch.hub looks before downloading.
|
| 94 |
+
_beat_checkpoint = Path(torch.hub.get_dir()) / "checkpoints" / "beat_this-final0.ckpt"
|
| 95 |
+
if not _beat_checkpoint.exists():
|
| 96 |
+
_beat_checkpoint.parent.mkdir(parents=True, exist_ok=True)
|
| 97 |
+
with contextlib.suppress(FileExistsError):
|
| 98 |
+
_beat_checkpoint.symlink_to(hf_hub_download(
|
| 99 |
+
"teamup-tech/Beat-This-weights", "final0.ckpt",
|
| 100 |
+
revision="4afbe376535aaab71b76ae2ca2d7c16b08877321",
|
| 101 |
+
))
|
| 102 |
|
| 103 |
CHECKPOINT_REPO = "teamup-tech/FST-AI-Music-Detection-checkpoints"
|
| 104 |
CHECKPOINT_DIR = Path("checkpoints")
|
|
|
|
| 114 |
try:
|
| 115 |
CHECKPOINT_DIR.mkdir(exist_ok=True)
|
| 116 |
for filename in ("Stage-1.ckpt", "Stage-2.ckpt"):
|
| 117 |
+
hf_hub_download(repo_id=CHECKPOINT_REPO, filename=filename, local_dir=str(CHECKPOINT_DIR),
|
| 118 |
+
revision="801f36e6103034bbd0d20fcbfa6a1a1ad5e919d3")
|
| 119 |
print("Checkpoints ready.")
|
| 120 |
except Exception as e:
|
| 121 |
checkpoint_error = str(e)
|