Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,6 +24,14 @@ from threading import Lock
|
|
| 24 |
import scipy.io.wavfile
|
| 25 |
import spaces
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
# Logging setup
|
| 28 |
logging.basicConfig(level=logging.INFO)
|
| 29 |
logger = logging.getLogger(__name__)
|
|
@@ -55,6 +63,12 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 55 |
use_autocast = device == "cuda"
|
| 56 |
logger.info(f"Using device: {device}")
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# ROFORMER_MODELS and OUTPUT_FORMATS
|
| 59 |
ROFORMER_MODELS = {
|
| 60 |
"Vocals": {
|
|
@@ -437,14 +451,8 @@ def roformer_separator(audio, model_key, seg_size, override_seg_size, overlap, p
|
|
| 437 |
|
| 438 |
@spaces.GPU
|
| 439 |
def auto_ensemble_process(audio, model_keys, seg_size=64, overlap=0.1, out_format="wav", use_tta="False", model_dir="/tmp/audio-separator-models/", output_dir="output", norm_thresh=0.9, amp_thresh=0.9, batch_size=1, ensemble_method="avg_wave", exclude_stems="", weights_str="", progress=gr.Progress(track_tqdm=True)):
|
| 440 |
-
global ensemble_state
|
| 441 |
temp_audio_path = None
|
| 442 |
-
max_retries = 2
|
| 443 |
start_time = time.time()
|
| 444 |
-
time_budget = 300 # ZeroGPU için işlem sınırı
|
| 445 |
-
max_models = 6
|
| 446 |
-
gpu_lock = Lock()
|
| 447 |
-
|
| 448 |
try:
|
| 449 |
if not audio:
|
| 450 |
raise ValueError("No audio file provided.")
|
|
@@ -662,7 +670,7 @@ def auto_ensemble_process(audio, model_keys, seg_size=64, overlap=0.1, out_forma
|
|
| 662 |
if torch.cuda.is_available():
|
| 663 |
torch.cuda.empty_cache()
|
| 664 |
logger.info("GPU memory cleared")
|
| 665 |
-
|
| 666 |
def update_roformer_models(category):
|
| 667 |
"""Update Roformer model dropdown based on selected category."""
|
| 668 |
choices = list(ROFORMER_MODELS.get(category, {}).keys()) or []
|
|
|
|
| 24 |
import scipy.io.wavfile
|
| 25 |
import spaces
|
| 26 |
|
| 27 |
+
# Global state definition
|
| 28 |
+
ensemble_state = {
|
| 29 |
+
"current_model_idx": 0,
|
| 30 |
+
"current_audio": None,
|
| 31 |
+
"processed_stems": [],
|
| 32 |
+
"model_outputs": {} # Her modelin stem'lerini saklamak için
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
# Logging setup
|
| 36 |
logging.basicConfig(level=logging.INFO)
|
| 37 |
logger = logging.getLogger(__name__)
|
|
|
|
| 63 |
use_autocast = device == "cuda"
|
| 64 |
logger.info(f"Using device: {device}")
|
| 65 |
|
| 66 |
+
# Constants
|
| 67 |
+
max_models = 6
|
| 68 |
+
max_retries = 2
|
| 69 |
+
time_budget = 300 # ZeroGPU için işlem sınırı
|
| 70 |
+
gpu_lock = Lock()
|
| 71 |
+
|
| 72 |
# ROFORMER_MODELS and OUTPUT_FORMATS
|
| 73 |
ROFORMER_MODELS = {
|
| 74 |
"Vocals": {
|
|
|
|
| 451 |
|
| 452 |
@spaces.GPU
|
| 453 |
def auto_ensemble_process(audio, model_keys, seg_size=64, overlap=0.1, out_format="wav", use_tta="False", model_dir="/tmp/audio-separator-models/", output_dir="output", norm_thresh=0.9, amp_thresh=0.9, batch_size=1, ensemble_method="avg_wave", exclude_stems="", weights_str="", progress=gr.Progress(track_tqdm=True)):
|
|
|
|
| 454 |
temp_audio_path = None
|
|
|
|
| 455 |
start_time = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
try:
|
| 457 |
if not audio:
|
| 458 |
raise ValueError("No audio file provided.")
|
|
|
|
| 670 |
if torch.cuda.is_available():
|
| 671 |
torch.cuda.empty_cache()
|
| 672 |
logger.info("GPU memory cleared")
|
| 673 |
+
|
| 674 |
def update_roformer_models(category):
|
| 675 |
"""Update Roformer model dropdown based on selected category."""
|
| 676 |
choices = list(ROFORMER_MODELS.get(category, {}).keys()) or []
|