Spaces:
Running
Running
Commit Β·
94bde3d
1
Parent(s): 39e7de4
Copy PANNs to multiple locations
Browse files
api.py
CHANGED
|
@@ -8,11 +8,8 @@ import gradio as gr
|
|
| 8 |
|
| 9 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
PANNS_CHECKPOINT = "/root/panns_data/Cnn14_mAP=0.431.pth"
|
| 14 |
-
|
| 15 |
-
os.makedirs("/root/panns_data", exist_ok=True)
|
| 16 |
|
| 17 |
if not os.path.exists(PANNS_CHECKPOINT):
|
| 18 |
print("π₯ Downloading PANNs checkpoint (~320MB)...")
|
|
@@ -21,10 +18,17 @@ if not os.path.exists(PANNS_CHECKPOINT):
|
|
| 21 |
"https://zenodo.org/record/3987831/files/Cnn14_mAP%3D0.431.pth?download=1",
|
| 22 |
PANNS_CHECKPOINT
|
| 23 |
)
|
| 24 |
-
print("β
PANNs checkpoint ready!")
|
| 25 |
else:
|
| 26 |
print(f"β
PANNs checkpoint exists: {os.path.getsize(PANNS_CHECKPOINT)} bytes")
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
DB_PATH = "library/snare_scout.sqlite"
|
| 29 |
if not os.path.exists(DB_PATH):
|
| 30 |
import requests
|
|
|
|
| 8 |
|
| 9 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 10 |
|
| 11 |
+
# Download PANNs checkpoint to current directory
|
| 12 |
+
PANNS_CHECKPOINT = "Cnn14_mAP=0.431.pth"
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
if not os.path.exists(PANNS_CHECKPOINT):
|
| 15 |
print("π₯ Downloading PANNs checkpoint (~320MB)...")
|
|
|
|
| 18 |
"https://zenodo.org/record/3987831/files/Cnn14_mAP%3D0.431.pth?download=1",
|
| 19 |
PANNS_CHECKPOINT
|
| 20 |
)
|
| 21 |
+
print(f"β
PANNs checkpoint ready! Size: {os.path.getsize(PANNS_CHECKPOINT)}")
|
| 22 |
else:
|
| 23 |
print(f"β
PANNs checkpoint exists: {os.path.getsize(PANNS_CHECKPOINT)} bytes")
|
| 24 |
|
| 25 |
+
# Also copy to where panns_inference might look
|
| 26 |
+
os.makedirs("/root/panns_data", exist_ok=True)
|
| 27 |
+
if not os.path.exists("/root/panns_data/Cnn14_mAP=0.431.pth"):
|
| 28 |
+
import shutil
|
| 29 |
+
shutil.copy(PANNS_CHECKPOINT, "/root/panns_data/Cnn14_mAP=0.431.pth")
|
| 30 |
+
print("β
Copied to /root/panns_data/")
|
| 31 |
+
|
| 32 |
DB_PATH = "library/snare_scout.sqlite"
|
| 33 |
if not os.path.exists(DB_PATH):
|
| 34 |
import requests
|