Update app.py
Browse files
app.py
CHANGED
|
@@ -4,15 +4,9 @@ from huggingface_hub import hf_hub_download
|
|
| 4 |
from audio_separator.separator import Separator
|
| 5 |
|
| 6 |
# --- Configuration ---
|
| 7 |
-
# REPO_ID: The repository containing the model weights
|
| 8 |
REPO_ID = "anvuew/dereverb_room"
|
| 9 |
-
|
| 10 |
-
# MODEL_FILENAME: specific .ckpt or .pth file in that repo
|
| 11 |
-
# IMPORTANT: Check the repo and replace this with the actual filename
|
| 12 |
MODEL_FILENAME = "dereverb_room_anvuew_sdr_13.7432.ckpt"
|
| 13 |
-
|
| 14 |
-
# CONFIG_FILENAME: specific .yaml file in that repo
|
| 15 |
-
# IMPORTANT: Check the repo and replace this with the actual filename
|
| 16 |
CONFIG_FILENAME = "dereverb_room_anvuew.yaml"
|
| 17 |
# ---------------------
|
| 18 |
|
|
@@ -25,28 +19,25 @@ def inference(audio_path):
|
|
| 25 |
config_path = hf_hub_download(repo_id=REPO_ID, filename=CONFIG_FILENAME)
|
| 26 |
|
| 27 |
print("Initializing separator...")
|
| 28 |
-
# Initialize
|
| 29 |
separator = Separator(
|
| 30 |
-
model_file_path=model_path,
|
| 31 |
-
config_file_path=config_path,
|
| 32 |
output_dir=".",
|
| 33 |
output_format="FLAC"
|
| 34 |
)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
print("Starting inference...")
|
| 37 |
-
# The model works by separating 'reverb' from the audio.
|
| 38 |
-
# We want the audio *without* reverb, which is usually the primary stem.
|
| 39 |
output_files = separator.separate(audio_path)
|
| 40 |
|
| 41 |
print(f"Separation complete. Outputs: {output_files}")
|
| 42 |
-
# Return the first output file
|
| 43 |
return output_files[0]
|
| 44 |
|
| 45 |
-
# Create Gradio Interface
|
| 46 |
with gr.Blocks(title="Dereverb Room Web UI") as demo:
|
| 47 |
gr.Markdown("# Dereverb Room Inference")
|
| 48 |
-
gr.Markdown(f"Inference using model from [{REPO_ID}](https://huggingface.co/{REPO_ID})")
|
| 49 |
-
|
| 50 |
with gr.Row():
|
| 51 |
input_audio = gr.Audio(label="Upload Audio", type="filepath")
|
| 52 |
output_audio = gr.Audio(label="Dereverbed Audio", type="filepath", interactive=False)
|
|
|
|
| 4 |
from audio_separator.separator import Separator
|
| 5 |
|
| 6 |
# --- Configuration ---
|
|
|
|
| 7 |
REPO_ID = "anvuew/dereverb_room"
|
| 8 |
+
# Filenames taken from your logs
|
|
|
|
|
|
|
| 9 |
MODEL_FILENAME = "dereverb_room_anvuew_sdr_13.7432.ckpt"
|
|
|
|
|
|
|
|
|
|
| 10 |
CONFIG_FILENAME = "dereverb_room_anvuew.yaml"
|
| 11 |
# ---------------------
|
| 12 |
|
|
|
|
| 19 |
config_path = hf_hub_download(repo_id=REPO_ID, filename=CONFIG_FILENAME)
|
| 20 |
|
| 21 |
print("Initializing separator...")
|
| 22 |
+
# Initialize WITHOUT model paths first
|
| 23 |
separator = Separator(
|
|
|
|
|
|
|
| 24 |
output_dir=".",
|
| 25 |
output_format="FLAC"
|
| 26 |
)
|
| 27 |
|
| 28 |
+
print(f"Loading model: {MODEL_FILENAME}...")
|
| 29 |
+
# Load the specific model and config using their absolute downloaded paths
|
| 30 |
+
separator.load_model(model_filename=model_path, config_filename=config_path)
|
| 31 |
+
|
| 32 |
print("Starting inference...")
|
|
|
|
|
|
|
| 33 |
output_files = separator.separate(audio_path)
|
| 34 |
|
| 35 |
print(f"Separation complete. Outputs: {output_files}")
|
| 36 |
+
# Return the first output file
|
| 37 |
return output_files[0]
|
| 38 |
|
|
|
|
| 39 |
with gr.Blocks(title="Dereverb Room Web UI") as demo:
|
| 40 |
gr.Markdown("# Dereverb Room Inference")
|
|
|
|
|
|
|
| 41 |
with gr.Row():
|
| 42 |
input_audio = gr.Audio(label="Upload Audio", type="filepath")
|
| 43 |
output_audio = gr.Audio(label="Dereverbed Audio", type="filepath", interactive=False)
|