Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,21 +6,9 @@ import tempfile
|
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
from sam_audio import SAMAudio, SAMAudioProcessor
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
checkpoint_path = hf_hub_download(repo_id=REPO_ID, filename="checkpoint.pt")
|
| 13 |
-
|
| 14 |
-
# 4. Load the model and apply your weights
|
| 15 |
-
model = SAMAudio.from_pretrained("ray-006/model-audio").to(device)
|
| 16 |
-
|
| 17 |
-
# Load your custom weights into the model
|
| 18 |
-
state_dict = torch.load(checkpoint_path, map_location=device)
|
| 19 |
-
model.load_state_dict(state_dict)
|
| 20 |
-
model.eval()
|
| 21 |
-
|
| 22 |
-
# Load processor (can be from the base or your repo if you uploaded config there)
|
| 23 |
-
processor = SAMAudioProcessor.from_pretrained("ray-006/model-audio")
|
| 24 |
|
| 25 |
def separate_audio(audio_path, description, reranking_candidates):
|
| 26 |
if audio_path is None or not description:
|
|
|
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
from sam_audio import SAMAudio, SAMAudioProcessor
|
| 8 |
|
| 9 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 10 |
+
model = SAMAudio.from_pretrained("facebook/sam-audio-large").to(device).eval()
|
| 11 |
+
processor = SAMAudioProcessor.from_pretrained("facebook/sam-audio-large")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def separate_audio(audio_path, description, reranking_candidates):
|
| 14 |
if audio_path is None or not description:
|