Spaces:
Sleeping
Sleeping
Commit ·
3cb9c07
1
Parent(s): 6471984
fix: move all output and storage directories from /tmp to local app subdirectories to fix Gradio serving issues on HF; explicitly allow results/checkpoints paths; set Audio type to filepath
Browse files- app.py +11 -1
- pipeline/constants.py +7 -0
- pipeline/inference.py +2 -1
- pipeline/mixing.py +2 -1
- pipeline/separation.py +2 -1
- pipeline/storage.py +1 -1
app.py
CHANGED
|
@@ -357,15 +357,18 @@ with gr.Blocks(
|
|
| 357 |
preview_vocals = gr.Audio(
|
| 358 |
label="Voz original (separada)",
|
| 359 |
interactive=False,
|
|
|
|
| 360 |
)
|
| 361 |
preview_converted = gr.Audio(
|
| 362 |
label="Voz convertida",
|
| 363 |
interactive=False,
|
|
|
|
| 364 |
)
|
| 365 |
gr.Markdown("**Resultado final:**")
|
| 366 |
final_output = gr.Audio(
|
| 367 |
label="Canción final (voz + instrumentos)",
|
| 368 |
interactive=False,
|
|
|
|
| 369 |
)
|
| 370 |
|
| 371 |
refresh_btn.click(
|
|
@@ -443,4 +446,11 @@ with gr.Blocks(
|
|
| 443 |
|
| 444 |
|
| 445 |
if __name__ == "__main__":
|
| 446 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
preview_vocals = gr.Audio(
|
| 358 |
label="Voz original (separada)",
|
| 359 |
interactive=False,
|
| 360 |
+
type="filepath",
|
| 361 |
)
|
| 362 |
preview_converted = gr.Audio(
|
| 363 |
label="Voz convertida",
|
| 364 |
interactive=False,
|
| 365 |
+
type="filepath",
|
| 366 |
)
|
| 367 |
gr.Markdown("**Resultado final:**")
|
| 368 |
final_output = gr.Audio(
|
| 369 |
label="Canción final (voz + instrumentos)",
|
| 370 |
interactive=False,
|
| 371 |
+
type="filepath",
|
| 372 |
)
|
| 373 |
|
| 374 |
refresh_btn.click(
|
|
|
|
| 446 |
|
| 447 |
|
| 448 |
if __name__ == "__main__":
|
| 449 |
+
os.makedirs("./results", exist_ok=True)
|
| 450 |
+
os.makedirs("./checkpoints/models", exist_ok=True)
|
| 451 |
+
app.launch(
|
| 452 |
+
allowed_paths=[
|
| 453 |
+
os.path.abspath("./results"),
|
| 454 |
+
os.path.abspath("./checkpoints"),
|
| 455 |
+
]
|
| 456 |
+
)
|
pipeline/constants.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
# Use a local directory instead of /tmp to ensure Gradio can serve the files easily on HF
|
| 4 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 5 |
+
RESULTS_DIR = os.path.join(BASE_DIR, "results")
|
| 6 |
+
|
| 7 |
+
os.makedirs(RESULTS_DIR, exist_ok=True)
|
pipeline/inference.py
CHANGED
|
@@ -23,7 +23,8 @@ except ImportError:
|
|
| 23 |
return fn
|
| 24 |
return decorator
|
| 25 |
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
# Cached models (loaded once, reused across calls)
|
| 29 |
_model_cache = {}
|
|
|
|
| 23 |
return fn
|
| 24 |
return decorator
|
| 25 |
|
| 26 |
+
from .constants import RESULTS_DIR
|
| 27 |
+
OUTPUT_DIR = os.path.join(RESULTS_DIR, "conversion")
|
| 28 |
|
| 29 |
# Cached models (loaded once, reused across calls)
|
| 30 |
_model_cache = {}
|
pipeline/mixing.py
CHANGED
|
@@ -15,7 +15,8 @@ from pedalboard import (
|
|
| 15 |
|
| 16 |
logger = logging.getLogger(__name__)
|
| 17 |
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
def _process_vocals(vocals: np.ndarray, sr: int) -> np.ndarray:
|
|
|
|
| 15 |
|
| 16 |
logger = logging.getLogger(__name__)
|
| 17 |
|
| 18 |
+
from .constants import RESULTS_DIR
|
| 19 |
+
OUTPUT_DIR = os.path.join(RESULTS_DIR, "mixing")
|
| 20 |
|
| 21 |
|
| 22 |
def _process_vocals(vocals: np.ndarray, sr: int) -> np.ndarray:
|
pipeline/separation.py
CHANGED
|
@@ -19,7 +19,8 @@ except ImportError:
|
|
| 19 |
return decorator
|
| 20 |
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
def _separate_audio_impl(audio_path: str, model_name: str = "htdemucs_ft"):
|
|
|
|
| 19 |
return decorator
|
| 20 |
|
| 21 |
|
| 22 |
+
from .constants import RESULTS_DIR
|
| 23 |
+
OUTPUT_DIR = os.path.join(RESULTS_DIR, "separation")
|
| 24 |
|
| 25 |
|
| 26 |
def _separate_audio_impl(audio_path: str, model_name: str = "htdemucs_ft"):
|
pipeline/storage.py
CHANGED
|
@@ -9,7 +9,7 @@ from datetime import datetime
|
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
MODELS_REPO_ID = None
|
| 12 |
-
LOCAL_MODELS_DIR = "
|
| 13 |
|
| 14 |
|
| 15 |
def init_storage(repo_id):
|
|
|
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
MODELS_REPO_ID = None
|
| 12 |
+
LOCAL_MODELS_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "checkpoints", "models")
|
| 13 |
|
| 14 |
|
| 15 |
def init_storage(repo_id):
|