Commit
·
c3eda24
1
Parent(s):
76aa7f1
Upload folder using huggingface_hub
Browse files- README.md +2 -11
- app.py +6 -0
- download.py +86 -0
- gui.py +652 -0
- helpers.py +232 -0
- inference.py +242 -0
- model.py +714 -0
- processing.py +320 -0
- requirements.txt +35 -0
README.md
CHANGED
@@ -1,12 +1,3 @@
|
|
1 |
-
---
|
2 |
-
title: Gecekondu Dubbing Studio
|
3 |
-
emoji: 👁
|
4 |
-
colorFrom: indigo
|
5 |
-
colorTo: green
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.20.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
+
# Gecekondu Dubbing Production Space
|
3 |
+
Bu Space, ses ayrıştırma ve dublaj işlemleri için profesyonel bir arayüz sunar.
|
app.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gui import create_interface
|
4 |
+
|
5 |
+
interface = create_interface()
|
6 |
+
interface.launch(server_name="0.0.0.0", server_port=7860)
|
download.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
import validators
|
4 |
+
import yt_dlp
|
5 |
+
import torch
|
6 |
+
import gdown
|
7 |
+
from urllib.parse import quote
|
8 |
+
from helpers import INPUT_DIR, COOKIE_PATH, clear_directory, clear_temp_folder, BASE_DIR
|
9 |
+
import yaml
|
10 |
+
|
11 |
+
def download_callback(url, download_type='direct', cookie_file=None):
|
12 |
+
clear_temp_folder("/tmp", exclude_items=["gradio", "config.json"])
|
13 |
+
clear_directory(INPUT_DIR)
|
14 |
+
os.makedirs(INPUT_DIR, exist_ok=True)
|
15 |
+
|
16 |
+
if not validators.url(url):
|
17 |
+
return None, "❌ Invalid URL", None, None, None, None
|
18 |
+
|
19 |
+
if cookie_file is not None:
|
20 |
+
try:
|
21 |
+
with open(cookie_file.name, "rb") as f:
|
22 |
+
cookie_content = f.read()
|
23 |
+
with open(COOKIE_PATH, "wb") as f:
|
24 |
+
f.write(cookie_content)
|
25 |
+
print("✅ Cookie file updated!")
|
26 |
+
except Exception as e:
|
27 |
+
print(f"⚠️ Cookie installation error: {str(e)}")
|
28 |
+
|
29 |
+
wav_path = None
|
30 |
+
download_success = False
|
31 |
+
|
32 |
+
if download_type == 'drive':
|
33 |
+
try:
|
34 |
+
file_id = re.search(r'/d/([^/]+)', url).group(1) if '/d/' in url else url.split('id=')[-1]
|
35 |
+
output_path = os.path.join(INPUT_DIR, "drive_download.wav")
|
36 |
+
gdown.download(f'https://drive.google.com/uc?id={file_id}', output_path, quiet=True)
|
37 |
+
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
|
38 |
+
wav_path = output_path
|
39 |
+
download_success = True
|
40 |
+
else:
|
41 |
+
raise Exception("File size zero or file not created")
|
42 |
+
except Exception as e:
|
43 |
+
error_msg = f"❌ Google Drive download error: {str(e)}"
|
44 |
+
print(error_msg)
|
45 |
+
return None, error_msg, None, None, None, None
|
46 |
+
else:
|
47 |
+
ydl_opts = {
|
48 |
+
'format': 'bestaudio/best',
|
49 |
+
'outtmpl': os.path.join(INPUT_DIR, '%(title)s.%(ext)s'),
|
50 |
+
'postprocessors': [{
|
51 |
+
'key': 'FFmpegExtractAudio',
|
52 |
+
'preferredcodec': 'wav',
|
53 |
+
'preferredquality': '0'
|
54 |
+
}],
|
55 |
+
'cookiefile': COOKIE_PATH if os.path.exists(COOKIE_PATH) else None,
|
56 |
+
'nocheckcertificate': True,
|
57 |
+
'ignoreerrors': True,
|
58 |
+
'retries': 3
|
59 |
+
}
|
60 |
+
try:
|
61 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
62 |
+
info_dict = ydl.extract_info(url, download=True)
|
63 |
+
temp_path = ydl.prepare_filename(info_dict)
|
64 |
+
wav_path = os.path.splitext(temp_path)[0] + '.wav'
|
65 |
+
if os.path.exists(wav_path):
|
66 |
+
download_success = True
|
67 |
+
else:
|
68 |
+
raise Exception("WAV conversion failed")
|
69 |
+
except Exception as e:
|
70 |
+
error_msg = f"❌ Download error: {str(e)}"
|
71 |
+
print(error_msg)
|
72 |
+
return None, error_msg, None, None, None, None
|
73 |
+
|
74 |
+
if download_success and wav_path:
|
75 |
+
for f in os.listdir(INPUT_DIR):
|
76 |
+
if f != os.path.basename(wav_path):
|
77 |
+
os.remove(os.path.join(INPUT_DIR, f))
|
78 |
+
return (
|
79 |
+
wav_path,
|
80 |
+
"🎉 Downloaded successfully!",
|
81 |
+
wav_path,
|
82 |
+
wav_path,
|
83 |
+
wav_path,
|
84 |
+
wav_path
|
85 |
+
)
|
86 |
+
return None, "❌ Download failed", None, None, None, None
|
gui.py
ADDED
@@ -0,0 +1,652 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import glob
|
4 |
+
import subprocess
|
5 |
+
from pathlib import Path
|
6 |
+
from datetime import datetime
|
7 |
+
from helpers import update_model_dropdown, handle_file_upload, clear_old_output, save_uploaded_file, update_file_list
|
8 |
+
from download import download_callback
|
9 |
+
from model import get_model_config, MODEL_CONFIGS
|
10 |
+
from processing import process_audio, auto_ensemble_process, ensemble_audio_fn
|
11 |
+
|
12 |
+
# BASE_DIR tanımı (BASE_PATH yerine)
|
13 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
14 |
+
|
15 |
+
# Arayüz oluşturma fonksiyonu
|
16 |
+
def create_interface():
|
17 |
+
# Gelişmiş ve profesyonel CSS
|
18 |
+
css = """
|
19 |
+
/* Genel Tema */
|
20 |
+
body {
|
21 |
+
background: url('/content/studio_bg.jpg') no-repeat center center fixed;
|
22 |
+
background-size: cover;
|
23 |
+
background-color: #1a0d0d; /* Daha koyu ve sofistike kırmızı ton */
|
24 |
+
min-height: 100vh;
|
25 |
+
margin: 0;
|
26 |
+
padding: 2rem;
|
27 |
+
font-family: 'Montserrat', sans-serif; /* Daha modern ve profesyonel font */
|
28 |
+
color: #D4A017; /* Altın tonu metin, lüks hissi */
|
29 |
+
overflow-x: hidden;
|
30 |
+
}
|
31 |
+
|
32 |
+
body::before {
|
33 |
+
content: '';
|
34 |
+
position: fixed;
|
35 |
+
top: 0;
|
36 |
+
left: 0;
|
37 |
+
width: 100%;
|
38 |
+
height: 100%;
|
39 |
+
background: linear-gradient(135deg, rgba(26, 13, 13, 0.9), rgba(45, 11, 11, 0.85));
|
40 |
+
z-index: -1;
|
41 |
+
}
|
42 |
+
|
43 |
+
/* Logo Stilleri */
|
44 |
+
.logo-container {
|
45 |
+
position: fixed;
|
46 |
+
top: 1.5rem;
|
47 |
+
left: 2rem;
|
48 |
+
display: flex;
|
49 |
+
align-items: center;
|
50 |
+
z-index: 3000;
|
51 |
+
background: rgba(0, 0, 0, 0.7);
|
52 |
+
padding: 0.5rem 1rem;
|
53 |
+
border-radius: 10px;
|
54 |
+
box-shadow: 0 4px 15px rgba(212, 160, 23, 0.3);
|
55 |
+
}
|
56 |
+
|
57 |
+
.logo-img {
|
58 |
+
width: 100px;
|
59 |
+
height: auto;
|
60 |
+
filter: drop-shadow(0 0 5px rgba(212, 160, 23, 0.5));
|
61 |
+
}
|
62 |
+
|
63 |
+
/* Başlık Stilleri */
|
64 |
+
.header-text {
|
65 |
+
text-align: center;
|
66 |
+
padding: 4rem 0 2rem;
|
67 |
+
color: #D4A017; /* Altın tonu, profesyonel ve dikkat çekici */
|
68 |
+
font-size: 3rem;
|
69 |
+
font-weight: 800;
|
70 |
+
text-transform: uppercase;
|
71 |
+
letter-spacing: 2px;
|
72 |
+
text-shadow: 0 0 15px rgba(212, 160, 23, 0.7), 0 0 5px rgba(255, 64, 64, 0.5);
|
73 |
+
z-index: 1500;
|
74 |
+
animation: text-glow 4s infinite ease-in-out;
|
75 |
+
}
|
76 |
+
|
77 |
+
/* Profesyonel Panel Stili */
|
78 |
+
.dubbing-panel {
|
79 |
+
background: rgba(26, 13, 13, 0.95);
|
80 |
+
border: 1px solid #D4A017;
|
81 |
+
border-radius: 12px;
|
82 |
+
padding: 1.5rem;
|
83 |
+
box-shadow: 0 8px 25px rgba(212, 160, 23, 0.2);
|
84 |
+
transition: transform 0.3s ease;
|
85 |
+
}
|
86 |
+
|
87 |
+
.dubbing-panel:hover {
|
88 |
+
transform: translateY(-5px);
|
89 |
+
}
|
90 |
+
|
91 |
+
/* Düğme Stilleri */
|
92 |
+
button {
|
93 |
+
background: linear-gradient(45deg, #800000, #A31818); /* Koyu kırmızıdan parlak kırmızıya */
|
94 |
+
border: 1px solid #D4A017 !important;
|
95 |
+
color: #FFF !important;
|
96 |
+
border-radius: 8px !important;
|
97 |
+
padding: 10px 20px !important;
|
98 |
+
font-weight: 600;
|
99 |
+
text-transform: uppercase;
|
100 |
+
letter-spacing: 1px;
|
101 |
+
transition: all 0.3s ease !important;
|
102 |
+
box-shadow: 0 4px 15px rgba(212, 160, 23, 0.3);
|
103 |
+
}
|
104 |
+
|
105 |
+
button:hover {
|
106 |
+
background: linear-gradient(45deg, #A31818, #D42F2F) !important;
|
107 |
+
transform: scale(1.05) !important;
|
108 |
+
box-shadow: 0 6px 20px rgba(212, 160, 23, 0.5) !important;
|
109 |
+
}
|
110 |
+
|
111 |
+
/* Yükleme Alanı */
|
112 |
+
.compact-upload.horizontal {
|
113 |
+
background: rgba(26, 13, 13, 0.9);
|
114 |
+
border: 1px solid #D4A017;
|
115 |
+
border-radius: 8px;
|
116 |
+
padding: 0.5rem 1rem;
|
117 |
+
display: flex;
|
118 |
+
align-items: center;
|
119 |
+
gap: 10px;
|
120 |
+
max-width: 450px;
|
121 |
+
transition: all 0.3s ease;
|
122 |
+
}
|
123 |
+
|
124 |
+
.compact-upload.horizontal:hover {
|
125 |
+
border-color: #FFD700; /* Parlak altın hover efekti */
|
126 |
+
background: rgba(45, 11, 11, 0.95);
|
127 |
+
}
|
128 |
+
|
129 |
+
.compact-upload.horizontal button {
|
130 |
+
background: #800000;
|
131 |
+
border: 1px solid #D4A017;
|
132 |
+
padding: 6px 12px;
|
133 |
+
font-size: 0.8rem;
|
134 |
+
}
|
135 |
+
|
136 |
+
/* Sekme Stilleri */
|
137 |
+
.gr-tab {
|
138 |
+
background: rgba(26, 13, 13, 0.9);
|
139 |
+
border: 1px solid #D4A017;
|
140 |
+
border-radius: 12px 12px 0 0;
|
141 |
+
padding: 0.75rem 1.5rem;
|
142 |
+
color: #D4A017;
|
143 |
+
font-weight: 600;
|
144 |
+
text-transform: uppercase;
|
145 |
+
transition: all 0.3s ease;
|
146 |
+
}
|
147 |
+
|
148 |
+
.gr-tab-selected {
|
149 |
+
background: #800000;
|
150 |
+
color: #FFF;
|
151 |
+
border-bottom: none;
|
152 |
+
box-shadow: 0 4px 15px rgba(212, 160, 23, 0.4);
|
153 |
+
}
|
154 |
+
|
155 |
+
/* Altbilgi */
|
156 |
+
.footer {
|
157 |
+
text-align: center;
|
158 |
+
padding: 1rem;
|
159 |
+
color: #D4A017;
|
160 |
+
font-size: 1rem;
|
161 |
+
font-weight: 500;
|
162 |
+
text-shadow: 0 0 5px rgba(212, 160, 23, 0.3);
|
163 |
+
position: relative;
|
164 |
+
z-index: 1001;
|
165 |
+
}
|
166 |
+
|
167 |
+
/* Animasyonlar */
|
168 |
+
@keyframes text-glow {
|
169 |
+
0% { text-shadow: 0 0 5px rgba(212, 160, 23, 0.5); }
|
170 |
+
50% { text-shadow: 0 0 20px rgba(212, 160, 23, 1), 0 0 10px rgba(255, 64, 64, 0.7); }
|
171 |
+
100% { text-shadow: 0 0 5px rgba(212, 160, 23, 0.5); }
|
172 |
+
}
|
173 |
+
"""
|
174 |
+
|
175 |
+
# Arayüz tasarımı
|
176 |
+
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
177 |
+
# Üst Panel: Logo ve Başlık
|
178 |
+
with gr.Row():
|
179 |
+
with gr.Column(scale=1, min_width=200):
|
180 |
+
gr.HTML("""
|
181 |
+
<div class="logo-container">
|
182 |
+
<img src="/content/gk_logo.png" alt="Gecekondu Dubbing" class="logo-img">
|
183 |
+
</div>
|
184 |
+
""")
|
185 |
+
with gr.Column(scale=4):
|
186 |
+
gr.HTML("""
|
187 |
+
<div class="header-text">
|
188 |
+
Gecekondu Dubbing Production
|
189 |
+
</div>
|
190 |
+
""")
|
191 |
+
|
192 |
+
with gr.Tabs():
|
193 |
+
with gr.Tab("Audio Separation", elem_id="separation_tab"):
|
194 |
+
with gr.Row(equal_height=True):
|
195 |
+
# Sol Panel - Kontroller
|
196 |
+
with gr.Column(scale=1, min_width=380):
|
197 |
+
with gr.Accordion("📥 Input & Model", open=True):
|
198 |
+
with gr.Tabs():
|
199 |
+
with gr.Tab("🖥 Upload"):
|
200 |
+
input_audio_file = gr.File(
|
201 |
+
file_types=[".wav", ".mp3", ".m4a", ".mp4", ".mkv", ".flac"],
|
202 |
+
elem_classes=["compact-upload", "horizontal", "x-narrow"],
|
203 |
+
label=""
|
204 |
+
)
|
205 |
+
|
206 |
+
with gr.Tab("📂 Path"):
|
207 |
+
file_path_input = gr.Textbox(placeholder="/path/to/audio.wav")
|
208 |
+
|
209 |
+
with gr.Row():
|
210 |
+
model_category = gr.Dropdown(
|
211 |
+
label="Category",
|
212 |
+
choices=list(MODEL_CONFIGS.keys()),
|
213 |
+
value="Vocal Models"
|
214 |
+
)
|
215 |
+
model_dropdown = gr.Dropdown(
|
216 |
+
label="Model",
|
217 |
+
choices=list(MODEL_CONFIGS["Vocal Models"].keys())
|
218 |
+
)
|
219 |
+
|
220 |
+
with gr.Accordion("⚙ Settings", open=False):
|
221 |
+
with gr.Row():
|
222 |
+
export_format = gr.Dropdown(
|
223 |
+
label="Format",
|
224 |
+
choices=['wav FLOAT', 'flac PCM_16', 'flac PCM_24'],
|
225 |
+
value='wav FLOAT'
|
226 |
+
)
|
227 |
+
chunk_size = gr.Dropdown(
|
228 |
+
label="Chunk Size",
|
229 |
+
choices=[352800, 485100],
|
230 |
+
value=352800,
|
231 |
+
info="Don't change unless you have specific requirements"
|
232 |
+
)
|
233 |
+
|
234 |
+
with gr.Row():
|
235 |
+
overlap = gr.Slider(2, 50, step=1, label="Overlap", value=2)
|
236 |
+
gr.Markdown("Recommended: 2-10 (Higher values increase quality but require more VRAM)")
|
237 |
+
use_tta = gr.Checkbox(label="TTA Boost")
|
238 |
+
|
239 |
+
with gr.Row():
|
240 |
+
use_demud_phaseremix_inst = gr.Checkbox(label="Phase Fix")
|
241 |
+
gr.Markdown("Advanced phase correction for instrumental tracks")
|
242 |
+
extract_instrumental = gr.Checkbox(label="Instrumental")
|
243 |
+
|
244 |
+
with gr.Row():
|
245 |
+
process_btn = gr.Button("🚀 Process", variant="primary")
|
246 |
+
clear_old_output_btn = gr.Button("🧹 Reset", variant="secondary")
|
247 |
+
clear_old_output_status = gr.Textbox(label="Status", interactive=False)
|
248 |
+
|
249 |
+
# Sağ Panel - Sonuçlar
|
250 |
+
with gr.Column(scale=2, min_width=800):
|
251 |
+
with gr.Tabs():
|
252 |
+
with gr.Tab("🎧 Main"):
|
253 |
+
with gr.Column():
|
254 |
+
original_audio = gr.Audio(label="Original", interactive=False)
|
255 |
+
with gr.Row():
|
256 |
+
vocals_audio = gr.Audio(label="Vocals", show_download_button=True)
|
257 |
+
instrumental_audio = gr.Audio(label="Instrumental", show_download_button=True)
|
258 |
+
|
259 |
+
with gr.Tab("🔍 Details"):
|
260 |
+
with gr.Column():
|
261 |
+
with gr.Row():
|
262 |
+
male_audio = gr.Audio(label="Male")
|
263 |
+
female_audio = gr.Audio(label="Female")
|
264 |
+
speech_audio = gr.Audio(label="Speech")
|
265 |
+
with gr.Row():
|
266 |
+
drum_audio = gr.Audio(label="Drums")
|
267 |
+
bass_audio = gr.Audio(label="Bass")
|
268 |
+
with gr.Row():
|
269 |
+
other_audio = gr.Audio(label="Other")
|
270 |
+
effects_audio = gr.Audio(label="Effects")
|
271 |
+
|
272 |
+
with gr.Tab("⚙ Advanced"):
|
273 |
+
with gr.Column():
|
274 |
+
with gr.Row():
|
275 |
+
phaseremix_audio = gr.Audio(label="Phase Remix")
|
276 |
+
dry_audio = gr.Audio(label="Dry")
|
277 |
+
with gr.Row():
|
278 |
+
music_audio = gr.Audio(label="Music")
|
279 |
+
karaoke_audio = gr.Audio(label="Karaoke")
|
280 |
+
bleed_audio = gr.Audio(label="Bleed")
|
281 |
+
|
282 |
+
with gr.Row():
|
283 |
+
gr.Markdown("""
|
284 |
+
<div style="
|
285 |
+
background: rgba(245,245,220,0.15);
|
286 |
+
padding: 1rem;
|
287 |
+
border-radius: 8px;
|
288 |
+
border-left: 3px solid #6c757d;
|
289 |
+
margin: 1rem 0 1.5rem 0;
|
290 |
+
">
|
291 |
+
<b>🔈 Processing Tip:</b> For noisy results, use <code>bleed_suppressor_v1</code>
|
292 |
+
or <code>denoisedebleed</code> models in the <i>"Denoise & Effect Removal"</i>
|
293 |
+
category to clean the output
|
294 |
+
</div>
|
295 |
+
""")
|
296 |
+
|
297 |
+
# Oto Ensemble Sekmesi
|
298 |
+
with gr.Tab("Auto Ensemble"):
|
299 |
+
with gr.Row():
|
300 |
+
with gr.Column():
|
301 |
+
with gr.Group():
|
302 |
+
auto_input_audio_file = gr.File(label="Upload file")
|
303 |
+
auto_file_path_input = gr.Textbox(
|
304 |
+
label="Or enter file path",
|
305 |
+
placeholder="Enter full path to audio file",
|
306 |
+
interactive=True
|
307 |
+
)
|
308 |
+
|
309 |
+
with gr.Accordion("⚙️ Advanced Settings", open=False):
|
310 |
+
with gr.Row():
|
311 |
+
auto_use_tta = gr.Checkbox(label="Use TTA", value=False)
|
312 |
+
auto_extract_instrumental = gr.Checkbox(label="Instrumental Only")
|
313 |
+
|
314 |
+
with gr.Row():
|
315 |
+
auto_overlap = gr.Slider(
|
316 |
+
label="Overlap",
|
317 |
+
minimum=2,
|
318 |
+
maximum=50,
|
319 |
+
value=2,
|
320 |
+
step=1
|
321 |
+
)
|
322 |
+
auto_chunk_size = gr.Dropdown(
|
323 |
+
label="Chunk Size",
|
324 |
+
choices=[352800, 485100],
|
325 |
+
value=352800
|
326 |
+
)
|
327 |
+
export_format2 = gr.Dropdown(
|
328 |
+
label="Output Format",
|
329 |
+
choices=['wav FLOAT', 'flac PCM_16', 'flac PCM_24'],
|
330 |
+
value='wav FLOAT'
|
331 |
+
)
|
332 |
+
|
333 |
+
# Model Seçim Bölümü
|
334 |
+
with gr.Group():
|
335 |
+
gr.Markdown("### 🧠 Model Selection")
|
336 |
+
with gr.Row():
|
337 |
+
auto_category_dropdown = gr.Dropdown(
|
338 |
+
label="Model Category",
|
339 |
+
choices=list(MODEL_CONFIGS.keys()),
|
340 |
+
value="Vocal Models"
|
341 |
+
)
|
342 |
+
|
343 |
+
# Model seçimi (tek seferde)
|
344 |
+
auto_model_dropdown = gr.Dropdown(
|
345 |
+
label="Select Models from Category",
|
346 |
+
choices=list(MODEL_CONFIGS["Vocal Models"].keys()),
|
347 |
+
multiselect=True,
|
348 |
+
max_choices=50,
|
349 |
+
interactive=True
|
350 |
+
)
|
351 |
+
|
352 |
+
# Seçilen modellerin listesi (ayrı kutucuk)
|
353 |
+
selected_models = gr.Dropdown(
|
354 |
+
label="Selected Models",
|
355 |
+
choices=[],
|
356 |
+
multiselect=True,
|
357 |
+
interactive=False
|
358 |
+
)
|
359 |
+
|
360 |
+
with gr.Row():
|
361 |
+
add_btn = gr.Button("➕ Add Selected", variant="secondary")
|
362 |
+
clear_btn = gr.Button("🗑️ Clear All", variant="stop")
|
363 |
+
|
364 |
+
# Ensemble Ayarları
|
365 |
+
with gr.Group():
|
366 |
+
gr.Markdown("### ⚡ Ensemble Settings")
|
367 |
+
with gr.Row():
|
368 |
+
auto_ensemble_type = gr.Dropdown(
|
369 |
+
label="Method",
|
370 |
+
choices=['avg_wave', 'median_wave', 'min_wave', 'max_wave',
|
371 |
+
'avg_fft', 'median_fft', 'min_fft', 'max_fft'],
|
372 |
+
value='avg_wave'
|
373 |
+
)
|
374 |
+
|
375 |
+
gr.Markdown("**Recommendation:** avg_wave and max_fft best results")
|
376 |
+
|
377 |
+
auto_process_btn = gr.Button("🚀 Start Processing", variant="primary")
|
378 |
+
|
379 |
+
with gr.Column():
|
380 |
+
with gr.Tabs():
|
381 |
+
with gr.Tab("🔊 Original Audio"):
|
382 |
+
original_audio2 = gr.Audio(
|
383 |
+
label="Original Audio",
|
384 |
+
interactive=False,
|
385 |
+
every=1,
|
386 |
+
elem_id="original_audio_player"
|
387 |
+
)
|
388 |
+
with gr.Tab("🎚️ Ensemble Result"):
|
389 |
+
auto_output_audio = gr.Audio(
|
390 |
+
label="Output Preview",
|
391 |
+
show_download_button=True,
|
392 |
+
interactive=False
|
393 |
+
)
|
394 |
+
|
395 |
+
auto_status = gr.Textbox(
|
396 |
+
label="Processing Status",
|
397 |
+
interactive=False,
|
398 |
+
placeholder="Waiting for processing...",
|
399 |
+
elem_classes="status-box"
|
400 |
+
)
|
401 |
+
|
402 |
+
gr.Markdown("""
|
403 |
+
<div style="
|
404 |
+
background: rgba(110, 142, 251, 0.1);
|
405 |
+
padding: 1.2rem;
|
406 |
+
border-radius: 12px;
|
407 |
+
border-left: 4px solid #6e8efb;
|
408 |
+
margin: 1rem 0;
|
409 |
+
backdrop-filter: blur(3px);
|
410 |
+
border: 1px solid rgba(255,255,255,0.2);
|
411 |
+
">
|
412 |
+
<div style="display: flex; align-items: start; gap: 1rem;">
|
413 |
+
<div style="
|
414 |
+
font-size: 1.4em;
|
415 |
+
color: #6e8efb;
|
416 |
+
margin-top: -2px;
|
417 |
+
">⚠️</div>
|
418 |
+
<div style="color: #2d3748;">
|
419 |
+
<h4 style="
|
420 |
+
margin: 0 0 0.8rem 0;
|
421 |
+
color: #4a5568;
|
422 |
+
font-weight: 600;
|
423 |
+
font-size: 1.1rem;
|
424 |
+
">
|
425 |
+
Model Selection Guidelines
|
426 |
+
</h4>
|
427 |
+
<ul style="
|
428 |
+
margin: 0;
|
429 |
+
padding-left: 1.2rem;
|
430 |
+
color: #4a5568;
|
431 |
+
line-height: 1.6;
|
432 |
+
">
|
433 |
+
<li><strong>Avoid cross-category mixing:</strong> Combining vocal and instrumental models may create unwanted blends</li>
|
434 |
+
<li><strong>Special model notes:</strong>
|
435 |
+
<ul style="padding-left: 1.2rem; margin: 0.5rem 0;">
|
436 |
+
<li>Duality models (v1/v2) - Output both stems</li>
|
437 |
+
<li>MDX23C Separator - Hybrid results</li>
|
438 |
+
</ul>
|
439 |
+
</li>
|
440 |
+
<li><strong>Best practice:</strong> Use 3-5 similar models from same category</li>
|
441 |
+
</ul>
|
442 |
+
<div style="
|
443 |
+
margin-top: 1rem;
|
444 |
+
padding: 0.8rem;
|
445 |
+
background: rgba(167, 119, 227, 0.1);
|
446 |
+
border-radius: 8px;
|
447 |
+
color: #6e8efb;
|
448 |
+
font-size: 0.9rem;
|
449 |
+
">
|
450 |
+
💡 Pro Tip: Start with "VOCALS-MelBand-Roformer BigBeta5e" + "VOCALS-BS-Roformer_1297" combination
|
451 |
+
</div>
|
452 |
+
</div>
|
453 |
+
</div>
|
454 |
+
</div>
|
455 |
+
""")
|
456 |
+
|
457 |
+
# İndirme Sekmesi
|
458 |
+
with gr.Tab("Download Sources"):
|
459 |
+
with gr.Row():
|
460 |
+
with gr.Column():
|
461 |
+
gr.Markdown("### 🗂️ Cloud Storage")
|
462 |
+
drive_url_input = gr.Textbox(label="Google Drive Shareable Link")
|
463 |
+
drive_download_btn = gr.Button("⬇️ Download from Drive", variant="secondary")
|
464 |
+
drive_download_status = gr.Textbox(label="Download Status")
|
465 |
+
drive_download_output = gr.File(label="Downloaded File", interactive=False)
|
466 |
+
|
467 |
+
with gr.Column():
|
468 |
+
gr.Markdown("### 🌐 Direct Links")
|
469 |
+
direct_url_input = gr.Textbox(label="Audio File URL")
|
470 |
+
direct_download_btn = gr.Button("⬇️ Download from URL", variant="secondary")
|
471 |
+
direct_download_status = gr.Textbox(label="Download Status")
|
472 |
+
direct_download_output = gr.File(label="Downloaded File", interactive=False)
|
473 |
+
|
474 |
+
with gr.Column():
|
475 |
+
gr.Markdown("### 🍪 Cookie Management")
|
476 |
+
cookie_file = gr.File(
|
477 |
+
label="Upload Cookies.txt",
|
478 |
+
file_types=[".txt"],
|
479 |
+
interactive=True,
|
480 |
+
elem_id="cookie_upload"
|
481 |
+
)
|
482 |
+
gr.Markdown("""
|
483 |
+
<div style="margin-left:15px; font-size:0.95em">
|
484 |
+
**📌 Why Needed?**
|
485 |
+
- Access age-restricted content
|
486 |
+
- Download private/unlisted videos
|
487 |
+
- Bypass regional restrictions
|
488 |
+
- Avoid YouTube download limits
|
489 |
+
|
490 |
+
**⚠️ Important Notes**
|
491 |
+
- NEVER share your cookie files!
|
492 |
+
- Refresh cookies when:
|
493 |
+
• Getting "403 Forbidden" errors
|
494 |
+
• Downloads suddenly stop
|
495 |
+
• Seeing "Session expired" messages
|
496 |
+
|
497 |
+
**🔄 Renewal Steps**
|
498 |
+
1. Install this <a href="https://chromewebstore.google.com/detail/get-cookiestxt-clean/ahmnmhfbokciafffnknlekllgcnafnie" target="_blank">Chrome extension</a>
|
499 |
+
2. Login to YouTube in Chrome
|
500 |
+
3. Click extension icon → "Export"
|
501 |
+
4. Upload the downloaded file here
|
502 |
+
|
503 |
+
**⏳ Cookie Lifespan**
|
504 |
+
- Normal sessions: 24 hours
|
505 |
+
- Sensitive operations: 1 hour
|
506 |
+
- Password changes: Immediate invalidation
|
507 |
+
</div>
|
508 |
+
""")
|
509 |
+
|
510 |
+
# Manuel Ensemble Sekmesi
|
511 |
+
with gr.Tab("🎚️ Manuel Ensemble"):
|
512 |
+
with gr.Row(equal_height=True):
|
513 |
+
with gr.Column(scale=1, min_width=400):
|
514 |
+
with gr.Accordion("📂 Input Sources", open=True):
|
515 |
+
with gr.Row():
|
516 |
+
refresh_btn = gr.Button("🔄 Refresh", variant="secondary", size="sm")
|
517 |
+
ensemble_type = gr.Dropdown(
|
518 |
+
label="Ensemble Algorithm",
|
519 |
+
choices=['avg_wave', 'median_wave', 'min_wave', 'max_wave',
|
520 |
+
'avg_fft', 'median_fft', 'min_fft', 'max_fft'],
|
521 |
+
value='avg_wave'
|
522 |
+
)
|
523 |
+
|
524 |
+
# Dosya listesini belirli bir yoldan al
|
525 |
+
file_path = os.path.join(Path.home(), 'Music-Source-Separation', 'output')
|
526 |
+
initial_files = glob.glob(f"{file_path}/*.wav") + glob.glob(os.path.join(BASE_DIR, 'Music-Source-Separation-Training', 'old_output', '*.wav'))
|
527 |
+
|
528 |
+
gr.Markdown("### Select Audio Files")
|
529 |
+
file_dropdown = gr.Dropdown(
|
530 |
+
choices=initial_files,
|
531 |
+
label="Available Files",
|
532 |
+
multiselect=True,
|
533 |
+
interactive=True,
|
534 |
+
elem_id="file-dropdown"
|
535 |
+
)
|
536 |
+
|
537 |
+
weights_input = gr.Textbox(
|
538 |
+
label="Custom Weights (comma separated)",
|
539 |
+
placeholder="Example: 0.8, 1.2, 1.0, ...",
|
540 |
+
info="Leave empty for equal weights"
|
541 |
+
)
|
542 |
+
|
543 |
+
# Sağ Panel - Sonuçlar
|
544 |
+
with gr.Column(scale=2, min_width=800):
|
545 |
+
with gr.Tabs():
|
546 |
+
with gr.Tab("🎧 Result Preview"):
|
547 |
+
ensemble_output_audio = gr.Audio(
|
548 |
+
label="Ensembled Output",
|
549 |
+
interactive=False,
|
550 |
+
show_download_button=True,
|
551 |
+
elem_id="output-audio"
|
552 |
+
)
|
553 |
+
|
554 |
+
with gr.Tab("📋 Processing Log"):
|
555 |
+
ensemble_status = gr.Textbox(
|
556 |
+
label="Processing Details",
|
557 |
+
interactive=False,
|
558 |
+
elem_id="log-box"
|
559 |
+
)
|
560 |
+
|
561 |
+
with gr.Row():
|
562 |
+
ensemble_process_btn = gr.Button(
|
563 |
+
"⚡ Process Ensemble",
|
564 |
+
variant="primary",
|
565 |
+
size="sm",
|
566 |
+
elem_id="process-btn"
|
567 |
+
)
|
568 |
+
|
569 |
+
gr.HTML("""
|
570 |
+
<div class="footer">
|
571 |
+
Presented by Gecekondu Production
|
572 |
+
</div>
|
573 |
+
""")
|
574 |
+
|
575 |
+
def update_models(category):
|
576 |
+
return gr.Dropdown(choices=list(MODEL_CONFIGS[category].keys()))
|
577 |
+
|
578 |
+
def add_models(new_models, existing_models):
|
579 |
+
updated = list(set(existing_models + new_models))
|
580 |
+
return gr.Dropdown(choices=updated, value=updated)
|
581 |
+
|
582 |
+
def clear_models():
|
583 |
+
return gr.Dropdown(choices=[], value=[])
|
584 |
+
|
585 |
+
# Event handlers
|
586 |
+
model_category.change(fn=update_model_dropdown, inputs=model_category, outputs=model_dropdown)
|
587 |
+
clear_old_output_btn.click(fn=clear_old_output, outputs=clear_old_output_status)
|
588 |
+
|
589 |
+
input_audio_file.upload(
|
590 |
+
fn=lambda x, y: handle_file_upload(x, y, is_auto_ensemble=False),
|
591 |
+
inputs=[input_audio_file, file_path_input],
|
592 |
+
outputs=[input_audio_file, original_audio]
|
593 |
+
)
|
594 |
+
file_path_input.change(
|
595 |
+
fn=lambda x, y: handle_file_upload(x, y, is_auto_ensemble=False),
|
596 |
+
inputs=[input_audio_file, file_path_input],
|
597 |
+
outputs=[input_audio_file, original_audio]
|
598 |
+
)
|
599 |
+
|
600 |
+
auto_input_audio_file.upload(
|
601 |
+
fn=lambda x, y: handle_file_upload(x, y, is_auto_ensemble=True),
|
602 |
+
inputs=[auto_input_audio_file, auto_file_path_input],
|
603 |
+
outputs=[auto_input_audio_file, original_audio2]
|
604 |
+
)
|
605 |
+
auto_file_path_input.change(
|
606 |
+
fn=lambda x, y: handle_file_upload(x, y, is_auto_ensemble=True),
|
607 |
+
inputs=[auto_input_audio_file, auto_file_path_input],
|
608 |
+
outputs=[auto_input_audio_file, original_audio2]
|
609 |
+
)
|
610 |
+
|
611 |
+
auto_category_dropdown.change(fn=update_models, inputs=auto_category_dropdown, outputs=auto_model_dropdown)
|
612 |
+
add_btn.click(fn=add_models, inputs=[auto_model_dropdown, selected_models], outputs=selected_models)
|
613 |
+
clear_btn.click(fn=clear_models, inputs=[], outputs=selected_models)
|
614 |
+
|
615 |
+
process_btn.click(
|
616 |
+
fn=process_audio,
|
617 |
+
inputs=[
|
618 |
+
input_audio_file, model_dropdown, chunk_size, overlap, export_format,
|
619 |
+
use_tta, use_demud_phaseremix_inst, extract_instrumental, gr.State(None), gr.State(None)
|
620 |
+
],
|
621 |
+
outputs=[
|
622 |
+
vocals_audio, instrumental_audio, phaseremix_audio, drum_audio, karaoke_audio,
|
623 |
+
bass_audio, other_audio, effects_audio, speech_audio, bleed_audio, music_audio,
|
624 |
+
dry_audio, male_audio, female_audio
|
625 |
+
]
|
626 |
+
)
|
627 |
+
|
628 |
+
auto_process_btn.click(
|
629 |
+
fn=auto_ensemble_process,
|
630 |
+
inputs=[
|
631 |
+
auto_input_audio_file, selected_models, auto_chunk_size, auto_overlap, export_format2,
|
632 |
+
auto_use_tta, auto_extract_instrumental, auto_ensemble_type, gr.State(None)
|
633 |
+
],
|
634 |
+
outputs=[auto_output_audio, auto_status]
|
635 |
+
)
|
636 |
+
|
637 |
+
drive_download_btn.click(
|
638 |
+
fn=download_callback,
|
639 |
+
inputs=[drive_url_input, gr.State('drive')],
|
640 |
+
outputs=[drive_download_output, drive_download_status, input_audio_file, auto_input_audio_file, original_audio, original_audio2]
|
641 |
+
)
|
642 |
+
|
643 |
+
direct_download_btn.click(
|
644 |
+
fn=download_callback,
|
645 |
+
inputs=[direct_url_input, gr.State('direct'), cookie_file],
|
646 |
+
outputs=[direct_download_output, direct_download_status, input_audio_file, auto_input_audio_file, original_audio, original_audio2]
|
647 |
+
)
|
648 |
+
|
649 |
+
refresh_btn.click(fn=update_file_list, outputs=file_dropdown)
|
650 |
+
ensemble_process_btn.click(fn=ensemble_audio_fn, inputs=[file_dropdown, ensemble_type, weights_input], outputs=[ensemble_output_audio, ensemble_status])
|
651 |
+
|
652 |
+
return demo
|
helpers.py
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil
|
3 |
+
import glob
|
4 |
+
import re
|
5 |
+
import subprocess
|
6 |
+
import random
|
7 |
+
import yaml
|
8 |
+
from pathlib import Path # Doğru kullanım: Path (küçük harfli 'path' değil)
|
9 |
+
import torch
|
10 |
+
import gradio as gr
|
11 |
+
import threading
|
12 |
+
import time
|
13 |
+
import librosa
|
14 |
+
import soundfile as sf
|
15 |
+
import numpy as np
|
16 |
+
import requests
|
17 |
+
import json
|
18 |
+
import locale
|
19 |
+
from datetime import datetime
|
20 |
+
import yt_dlp
|
21 |
+
import validators
|
22 |
+
from pytube import YouTube
|
23 |
+
from google.colab import auth
|
24 |
+
from googleapiclient.discovery import build
|
25 |
+
from googleapiclient.http import MediaIoBaseDownload
|
26 |
+
import io
|
27 |
+
import math
|
28 |
+
import hashlib
|
29 |
+
import gc
|
30 |
+
import psutil
|
31 |
+
import concurrent.futures
|
32 |
+
from tqdm import tqdm
|
33 |
+
from google.oauth2.credentials import Credentials
|
34 |
+
import tempfile
|
35 |
+
from urllib.parse import urlparse, quote
|
36 |
+
import gdown
|
37 |
+
import argparse
|
38 |
+
from tqdm.auto import tqdm
|
39 |
+
import torch.nn as nn
|
40 |
+
from model import get_model_config, MODEL_CONFIGS
|
41 |
+
|
42 |
+
# Temel dizinler
|
43 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
44 |
+
INPUT_DIR = os.path.join(BASE_DIR, "input")
|
45 |
+
OUTPUT_DIR = os.path.join(BASE_DIR, "output")
|
46 |
+
OLD_OUTPUT_DIR = os.path.join(BASE_DIR, "old_output")
|
47 |
+
AUTO_ENSEMBLE_TEMP = os.path.join(BASE_DIR, "auto_ensemble_temp")
|
48 |
+
AUTO_ENSEMBLE_OUTPUT = os.path.join(BASE_DIR, "ensemble_folder")
|
49 |
+
VIDEO_TEMP = os.path.join(BASE_DIR, "video_temp")
|
50 |
+
ENSEMBLE_DIR = os.path.join(BASE_DIR, "ensemble")
|
51 |
+
COOKIE_PATH = os.path.join(BASE_DIR, "cookies.txt")
|
52 |
+
INFERENCE_SCRIPT_PATH = os.path.join(BASE_DIR, "inference.py")
|
53 |
+
|
54 |
+
# Dizinleri oluştur
|
55 |
+
for directory in [BASE_DIR, INPUT_DIR, OUTPUT_DIR, OLD_OUTPUT_DIR, AUTO_ENSEMBLE_TEMP, AUTO_ENSEMBLE_OUTPUT, VIDEO_TEMP, ENSEMBLE_DIR]:
|
56 |
+
os.makedirs(directory, exist_ok=True)
|
57 |
+
|
58 |
+
# YAML için özel sınıf ve yapılandırıcı
|
59 |
+
class IndentDumper(yaml.Dumper):
|
60 |
+
def increase_indent(self, flow=False, indentless=False):
|
61 |
+
return super(IndentDumper, self).increase_indent(flow, False)
|
62 |
+
|
63 |
+
def tuple_constructor(loader, node):
|
64 |
+
"""Loads a tuple from a YAML sequence."""
|
65 |
+
values = loader.construct_sequence(node)
|
66 |
+
return tuple(values)
|
67 |
+
|
68 |
+
# PyYAML ile tuple constructor'ı kaydet
|
69 |
+
yaml.SafeLoader.add_constructor('tag:yaml.org,2002:python/tuple', tuple_constructor)
|
70 |
+
|
71 |
+
def update_model_dropdown(category):
|
72 |
+
"""Kategoriye göre model dropdown'ını günceller."""
|
73 |
+
return gr.Dropdown(choices=list(MODEL_CONFIGS[category].keys()), label="Model")
|
74 |
+
|
75 |
+
# Dosya yükleme işlevi (güncellenmiş)
|
76 |
+
def handle_file_upload(uploaded_file, file_path, is_auto_ensemble=False):
|
77 |
+
clear_temp_folder("/tmp", exclude_items=["gradio", "config.json"])
|
78 |
+
clear_directory(INPUT_DIR)
|
79 |
+
os.makedirs(INPUT_DIR, exist_ok=True)
|
80 |
+
clear_directory(INPUT_DIR)
|
81 |
+
if uploaded_file:
|
82 |
+
# Yüklenen dosyayı INPUT_DIR'a kaydet
|
83 |
+
target_path = save_uploaded_file(uploaded_file, is_input=True)
|
84 |
+
return target_path, target_path
|
85 |
+
elif file_path and os.path.exists(file_path):
|
86 |
+
# Mevcut dosyayı INPUT_DIR'a kopyala
|
87 |
+
target_path = os.path.join(INPUT_DIR, os.path.basename(file_path))
|
88 |
+
shutil.copy(file_path, target_path)
|
89 |
+
return target_path, target_path
|
90 |
+
return None, None
|
91 |
+
|
92 |
+
def clear_directory(directory):
|
93 |
+
"""Deletes all files in the given directory."""
|
94 |
+
files = glob.glob(os.path.join(directory, '*'))
|
95 |
+
for f in files:
|
96 |
+
try:
|
97 |
+
os.remove(f)
|
98 |
+
except Exception as e:
|
99 |
+
print(f"{f} could not be deleted: {e}")
|
100 |
+
|
101 |
+
def clear_temp_folder(folder_path, exclude_items=None):
|
102 |
+
"""Safely clears contents of a directory while preserving specified items."""
|
103 |
+
try:
|
104 |
+
if not os.path.exists(folder_path):
|
105 |
+
print(f"⚠️ Directory does not exist: {folder_path}")
|
106 |
+
return False
|
107 |
+
if not os.path.isdir(folder_path):
|
108 |
+
print(f"⚠️ Path is not a directory: {folder_path}")
|
109 |
+
return False
|
110 |
+
exclude_items = exclude_items or []
|
111 |
+
for item_name in os.listdir(folder_path):
|
112 |
+
item_path = os.path.join(folder_path, item_name)
|
113 |
+
if item_name in exclude_items:
|
114 |
+
continue
|
115 |
+
try:
|
116 |
+
if os.path.isfile(item_path) or os.path.islink(item_path):
|
117 |
+
os.unlink(item_path)
|
118 |
+
elif os.path.isdir(item_path):
|
119 |
+
shutil.rmtree(item_path)
|
120 |
+
except Exception as e:
|
121 |
+
print(f"⚠️ Error deleting {item_path}: {str(e)}")
|
122 |
+
return True
|
123 |
+
except Exception as e:
|
124 |
+
print(f"❌ Critical error: {str(e)}")
|
125 |
+
return False
|
126 |
+
|
127 |
+
def clear_old_output():
|
128 |
+
old_output_folder = os.path.join(BASE_DIR, 'old_output')
|
129 |
+
try:
|
130 |
+
if not os.path.exists(old_output_folder):
|
131 |
+
return "❌ Old output folder does not exist"
|
132 |
+
shutil.rmtree(old_output_folder)
|
133 |
+
os.makedirs(old_output_folder, exist_ok=True)
|
134 |
+
return "✅ Old outputs successfully cleared!"
|
135 |
+
except Exception as e:
|
136 |
+
return f"🔥 Error: {str(e)}"
|
137 |
+
|
138 |
+
def shorten_filename(filename, max_length=30):
|
139 |
+
"""Shortens a filename to a specified maximum length."""
|
140 |
+
base, ext = os.path.splitext(filename)
|
141 |
+
if len(base) <= max_length:
|
142 |
+
return filename
|
143 |
+
return base[:15] + "..." + base[-10:] + ext
|
144 |
+
|
145 |
+
def clean_filename(title):
|
146 |
+
"""Removes special characters from a filename."""
|
147 |
+
return re.sub(r'[^\w\-_\. ]', '', title).strip()
|
148 |
+
|
149 |
+
def convert_to_wav(file_path):
|
150 |
+
"""Converts the audio file to WAV format."""
|
151 |
+
original_filename = os.path.basename(file_path)
|
152 |
+
filename, ext = os.path.splitext(original_filename)
|
153 |
+
if ext.lower() == '.wav':
|
154 |
+
return file_path
|
155 |
+
wav_output = os.path.join(ENSEMBLE_DIR, f"{filename}.wav")
|
156 |
+
try:
|
157 |
+
command = [
|
158 |
+
'ffmpeg', '-y', '-i', file_path,
|
159 |
+
'-acodec', 'pcm_s16le', '-ar', '44100', wav_output
|
160 |
+
]
|
161 |
+
subprocess.run(command, check=True, capture_output=True)
|
162 |
+
return wav_output
|
163 |
+
except subprocess.CalledProcessError as e:
|
164 |
+
print(f"FFmpeg Error ({e.returncode}): {e.stderr.decode()}")
|
165 |
+
return None
|
166 |
+
|
167 |
+
def generate_random_port():
|
168 |
+
"""Generates a random port number."""
|
169 |
+
return random.randint(1000, 9000)
|
170 |
+
|
171 |
+
def update_file_list():
|
172 |
+
# OUTPUT_DIR ve OLD_OUTPUT_DIR'dan .wav dosyalarını al
|
173 |
+
output_files = glob.glob(os.path.join(OUTPUT_DIR, "*.wav"))
|
174 |
+
old_output_files = glob.glob(os.path.join(OLD_OUTPUT_DIR, "*.wav"))
|
175 |
+
|
176 |
+
# Dosya listesini birleştir
|
177 |
+
files = output_files + old_output_files
|
178 |
+
|
179 |
+
# Gradio Dropdown için seçenekleri döndür
|
180 |
+
return gr.Dropdown(choices=files)
|
181 |
+
|
182 |
+
def save_uploaded_file(uploaded_file, is_input=False, target_dir=None):
|
183 |
+
"""Saves an uploaded file to the specified directory."""
|
184 |
+
media_extensions = ['.mp3', '.wav', '.flac', '.aac', '.ogg', '.m4a', '.mp4']
|
185 |
+
target_dir = target_dir or (INPUT_DIR if is_input else OUTPUT_DIR)
|
186 |
+
timestamp_patterns = [
|
187 |
+
r'_\d{8}_\d{6}_\d{6}$', r'_\d{14}$', r'_\d{10}$', r'_\d+$'
|
188 |
+
]
|
189 |
+
|
190 |
+
if hasattr(uploaded_file, 'name'):
|
191 |
+
original_filename = os.path.basename(uploaded_file.name)
|
192 |
+
else:
|
193 |
+
original_filename = os.path.basename(str(uploaded_file))
|
194 |
+
|
195 |
+
if is_input:
|
196 |
+
base_filename = original_filename
|
197 |
+
for pattern in timestamp_patterns:
|
198 |
+
base_filename = re.sub(pattern, '', base_filename)
|
199 |
+
for ext in media_extensions:
|
200 |
+
base_filename = base_filename.replace(ext, '')
|
201 |
+
file_ext = next(
|
202 |
+
(ext for ext in media_extensions if original_filename.lower().endswith(ext)),
|
203 |
+
'.wav'
|
204 |
+
)
|
205 |
+
clean_filename = f"{base_filename.strip('_- ')}{file_ext}"
|
206 |
+
else:
|
207 |
+
clean_filename = original_filename
|
208 |
+
|
209 |
+
target_path = os.path.join(target_dir, clean_filename)
|
210 |
+
os.makedirs(target_dir, exist_ok=True)
|
211 |
+
|
212 |
+
if os.path.exists(target_path):
|
213 |
+
os.remove(target_path)
|
214 |
+
|
215 |
+
if hasattr(uploaded_file, 'read'):
|
216 |
+
with open(target_path, "wb") as f:
|
217 |
+
f.write(uploaded_file.read())
|
218 |
+
else:
|
219 |
+
shutil.copy(uploaded_file, target_path)
|
220 |
+
|
221 |
+
print(f"File saved successfully: {os.path.basename(target_path)}")
|
222 |
+
return target_path
|
223 |
+
|
224 |
+
def move_old_files(output_folder):
|
225 |
+
"""Moves old files to the old_output directory."""
|
226 |
+
os.makedirs(OLD_OUTPUT_DIR, exist_ok=True)
|
227 |
+
for filename in os.listdir(output_folder):
|
228 |
+
file_path = os.path.join(output_folder, filename)
|
229 |
+
if os.path.isfile(file_path):
|
230 |
+
new_filename = f"{os.path.splitext(filename)[0]}_old{os.path.splitext(filename)[1]}"
|
231 |
+
new_file_path = os.path.join(OLD_OUTPUT_DIR, new_filename)
|
232 |
+
shutil.move(file_path, new_file_path)
|
inference.py
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding: utf-8
|
2 |
+
__author__ = 'Roman Solovyev (ZFTurbo): https://github.com/ZFTurbo/'
|
3 |
+
|
4 |
+
import argparse
|
5 |
+
import time
|
6 |
+
import librosa
|
7 |
+
from tqdm.auto import tqdm
|
8 |
+
import sys
|
9 |
+
import os
|
10 |
+
import glob
|
11 |
+
import torch
|
12 |
+
import soundfile as sf
|
13 |
+
import torch.nn as nn
|
14 |
+
from datetime import datetime
|
15 |
+
import numpy as np
|
16 |
+
import librosa
|
17 |
+
|
18 |
+
# Using the embedded version of Python can also correctly import the utils module.
|
19 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
20 |
+
sys.path.append(current_dir)
|
21 |
+
|
22 |
+
from utils import demix, get_model_from_config, normalize_audio, denormalize_audio
|
23 |
+
from utils import prefer_target_instrument, apply_tta, load_start_checkpoint, load_lora_weights
|
24 |
+
|
25 |
+
import warnings
|
26 |
+
warnings.filterwarnings("ignore")
|
27 |
+
|
28 |
+
|
29 |
+
def shorten_filename(filename, max_length=30):
|
30 |
+
"""
|
31 |
+
Shortens a filename to a specified maximum length
|
32 |
+
|
33 |
+
Args:
|
34 |
+
filename (str): The filename to be shortened
|
35 |
+
max_length (int): Maximum allowed length for the filename
|
36 |
+
|
37 |
+
Returns:
|
38 |
+
str: Shortened filename
|
39 |
+
"""
|
40 |
+
base, ext = os.path.splitext(filename)
|
41 |
+
if len(base) <= max_length:
|
42 |
+
return filename
|
43 |
+
|
44 |
+
# Take first 15 and last 10 characters
|
45 |
+
shortened = base[:15] + "..." + base[-10:] + ext
|
46 |
+
return shortened
|
47 |
+
|
48 |
+
def get_soundfile_subtype(pcm_type, is_float=False):
|
49 |
+
"""
|
50 |
+
PCM türüne göre uygun soundfile subtypei belirle
|
51 |
+
|
52 |
+
Args:
|
53 |
+
pcm_type (str): PCM türü ('PCM_16', 'PCM_24', 'FLOAT')
|
54 |
+
is_float (bool): Float formatı kullanılıp kullanılmayacağı
|
55 |
+
|
56 |
+
Returns:
|
57 |
+
str: Soundfile subtype
|
58 |
+
"""
|
59 |
+
if is_float:
|
60 |
+
return 'FLOAT'
|
61 |
+
|
62 |
+
subtype_map = {
|
63 |
+
'PCM_16': 'PCM_16',
|
64 |
+
'PCM_24': 'PCM_24',
|
65 |
+
'FLOAT': 'FLOAT'
|
66 |
+
}
|
67 |
+
return subtype_map.get(pcm_type, 'FLOAT')
|
68 |
+
|
69 |
+
def run_folder(model, args, config, device, verbose: bool = False):
|
70 |
+
start_time = time.time()
|
71 |
+
model.eval()
|
72 |
+
|
73 |
+
mixture_paths = sorted(glob.glob(os.path.join(args.input_folder, '*.*')))
|
74 |
+
sample_rate = getattr(config.audio, 'sample_rate', 44100)
|
75 |
+
|
76 |
+
print(f"Total files found: {len(mixture_paths)}. Using sample rate: {sample_rate}")
|
77 |
+
|
78 |
+
instruments = prefer_target_instrument(config)[:]
|
79 |
+
os.makedirs(args.store_dir, exist_ok=True)
|
80 |
+
|
81 |
+
# Dosya sayısını ve progress için değişkenler
|
82 |
+
total_files = len(mixture_paths)
|
83 |
+
current_file = 0
|
84 |
+
|
85 |
+
# Progress tracking
|
86 |
+
for path in mixture_paths:
|
87 |
+
try:
|
88 |
+
# Dosya işleme başlangıcı
|
89 |
+
current_file += 1
|
90 |
+
print(f"Processing file {current_file}/{total_files}")
|
91 |
+
|
92 |
+
mix, sr = librosa.load(path, sr=sample_rate, mono=False)
|
93 |
+
except Exception as e:
|
94 |
+
print(f'Cannot read track: {path}')
|
95 |
+
print(f'Error message: {str(e)}')
|
96 |
+
continue
|
97 |
+
|
98 |
+
mix_orig = mix.copy()
|
99 |
+
if 'normalize' in config.inference:
|
100 |
+
if config.inference['normalize'] is True:
|
101 |
+
mix, norm_params = normalize_audio(mix)
|
102 |
+
|
103 |
+
waveforms_orig = demix(config, model, mix, device, model_type=args.model_type)
|
104 |
+
|
105 |
+
if args.use_tta:
|
106 |
+
waveforms_orig = apply_tta(config, model, mix, waveforms_orig, device, args.model_type)
|
107 |
+
|
108 |
+
if args.demud_phaseremix_inst:
|
109 |
+
print(f"Demudding track (phase remix - instrumental): {path}")
|
110 |
+
instr = 'vocals' if 'vocals' in instruments else instruments[0]
|
111 |
+
instruments.append('instrumental_phaseremix')
|
112 |
+
if 'instrumental' not in instruments and 'Instrumental' not in instruments:
|
113 |
+
mix_modified = mix_orig - 2*waveforms_orig[instr]
|
114 |
+
mix_modified_ = mix_modified.copy()
|
115 |
+
|
116 |
+
waveforms_modified = demix(config, model, mix_modified, device, model_type=args.model_type)
|
117 |
+
if args.use_tta:
|
118 |
+
waveforms_modified = apply_tta(config, model, mix_modified, waveforms_modified, device, args.model_type)
|
119 |
+
|
120 |
+
waveforms_orig['instrumental_phaseremix'] = mix_orig + waveforms_modified[instr]
|
121 |
+
else:
|
122 |
+
mix_modified = 2*waveforms_orig[instr] - mix_orig
|
123 |
+
mix_modified_ = mix_modified.copy()
|
124 |
+
|
125 |
+
waveforms_modified = demix(config, model, mix_modified, device, model_type=args.model_type)
|
126 |
+
if args.use_tta:
|
127 |
+
waveforms_modified = apply_tta(config, model, mix_modified, waveforms_orig, device, args.model_type)
|
128 |
+
|
129 |
+
waveforms_orig['instrumental_phaseremix'] = mix_orig + mix_modified_ - waveforms_modified[instr]
|
130 |
+
|
131 |
+
if args.extract_instrumental:
|
132 |
+
instr = 'vocals' if 'vocals' in instruments else instruments[0]
|
133 |
+
waveforms_orig['instrumental'] = mix_orig - waveforms_orig[instr]
|
134 |
+
if 'instrumental' not in instruments:
|
135 |
+
instruments.append('instrumental')
|
136 |
+
|
137 |
+
for instr in instruments:
|
138 |
+
estimates = waveforms_orig[instr]
|
139 |
+
if 'normalize' in config.inference:
|
140 |
+
if config.inference['normalize'] is True:
|
141 |
+
estimates = denormalize_audio(estimates, norm_params)
|
142 |
+
|
143 |
+
# Dosya formatı ve PCM türü belirleme
|
144 |
+
is_float = getattr(args, 'export_format', '').startswith('wav FLOAT')
|
145 |
+
codec = 'flac' if getattr(args, 'flac_file', False) else 'wav'
|
146 |
+
|
147 |
+
# Subtype belirleme
|
148 |
+
if codec == 'flac':
|
149 |
+
subtype = get_soundfile_subtype(args.pcm_type, is_float)
|
150 |
+
else:
|
151 |
+
subtype = get_soundfile_subtype('FLOAT', is_float)
|
152 |
+
|
153 |
+
shortened_filename = shorten_filename(os.path.basename(path))
|
154 |
+
output_filename = f"{shortened_filename}_{instr}.{codec}"
|
155 |
+
output_path = os.path.join(args.store_dir, output_filename)
|
156 |
+
|
157 |
+
sf.write(output_path, estimates.T, sr, subtype=subtype)
|
158 |
+
|
159 |
+
# Progress yüzdesi hesaplama
|
160 |
+
progress_percent = int((current_file / total_files) * 100)
|
161 |
+
print(f"Progress: {progress_percent}%")
|
162 |
+
|
163 |
+
print(f"Elapsed time: {time.time() - start_time:.2f} seconds.")
|
164 |
+
|
165 |
+
def proc_folder(args):
|
166 |
+
parser = argparse.ArgumentParser()
|
167 |
+
parser.add_argument("--model_type", type=str, default='mdx23c',
|
168 |
+
help="Model type (bandit, bs_roformer, mdx23c, etc.)")
|
169 |
+
parser.add_argument("--config_path", type=str, help="Path to config file")
|
170 |
+
parser.add_argument("--demud_phaseremix_inst", action='store_true', help="demud_phaseremix_inst")
|
171 |
+
parser.add_argument("--start_check_point", type=str, default='',
|
172 |
+
help="Initial checkpoint to valid weights")
|
173 |
+
parser.add_argument("--input_folder", type=str, help="Folder with mixtures to process")
|
174 |
+
parser.add_argument("--audio_path", type=str, help="Path to a single audio file to process") # Yeni argüman
|
175 |
+
parser.add_argument("--store_dir", default="", type=str, help="Path to store results")
|
176 |
+
parser.add_argument("--device_ids", nargs='+', type=int, default=0,
|
177 |
+
help='List of GPU IDs')
|
178 |
+
parser.add_argument("--extract_instrumental", action='store_true',
|
179 |
+
help="Invert vocals to get instrumental if provided")
|
180 |
+
parser.add_argument("--force_cpu", action='store_true',
|
181 |
+
help="Force the use of CPU even if CUDA is available")
|
182 |
+
parser.add_argument("--flac_file", action='store_true',
|
183 |
+
help="Output flac file instead of wav")
|
184 |
+
parser.add_argument("--export_format", type=str,
|
185 |
+
choices=['wav FLOAT', 'flac PCM_16', 'flac PCM_24'],
|
186 |
+
default='flac PCM_24',
|
187 |
+
help="Export format and PCM type")
|
188 |
+
parser.add_argument("--pcm_type", type=str,
|
189 |
+
choices=['PCM_16', 'PCM_24'],
|
190 |
+
default='PCM_24',
|
191 |
+
help="PCM type for FLAC files")
|
192 |
+
parser.add_argument("--use_tta", action='store_true',
|
193 |
+
help="Enable test time augmentation")
|
194 |
+
parser.add_argument("--lora_checkpoint", type=str, default='',
|
195 |
+
help="Initial checkpoint to LoRA weights")
|
196 |
+
|
197 |
+
# Argümanları ayrıştır
|
198 |
+
parsed_args = parser.parse_args(args)
|
199 |
+
|
200 |
+
# Burada parsed_args.audio_path ile ses dosyası yolunu kullanabilirsiniz
|
201 |
+
print(f"Audio path provided: {parsed_args.audio_path}")
|
202 |
+
|
203 |
+
if args is None:
|
204 |
+
args = parser.parse_args()
|
205 |
+
else:
|
206 |
+
args = parser.parse_args(args)
|
207 |
+
|
208 |
+
# Cihaz seçimi
|
209 |
+
device = "cpu"
|
210 |
+
if args.force_cpu:
|
211 |
+
device = "cpu"
|
212 |
+
elif torch.cuda.is_available():
|
213 |
+
print('CUDA is available, use --force_cpu to disable it.')
|
214 |
+
device = f'cuda:{args.device_ids[0]}' if type(args.device_ids) == list else f'cuda:{args.device_ids}'
|
215 |
+
elif torch.backends.mps.is_available():
|
216 |
+
device = "mps"
|
217 |
+
|
218 |
+
print("Using device: ", device)
|
219 |
+
|
220 |
+
model_load_start_time = time.time()
|
221 |
+
torch.backends.cudnn.benchmark = True
|
222 |
+
|
223 |
+
model, config = get_model_from_config(args.model_type, args.config_path)
|
224 |
+
|
225 |
+
if args.start_check_point != '':
|
226 |
+
load_start_checkpoint(args, model, type_='inference')
|
227 |
+
|
228 |
+
print("Instruments: {}".format(config.training.instruments))
|
229 |
+
|
230 |
+
# Çoklu CUDA GPU kullanımı
|
231 |
+
if type(args.device_ids) == list and len(args.device_ids) > 1 and not args.force_cpu:
|
232 |
+
model = nn.DataParallel(model, device_ids=args.device_ids)
|
233 |
+
|
234 |
+
model = model.to(device)
|
235 |
+
|
236 |
+
print("Model load time: {:.2f} sec".format(time.time() - model_load_start_time))
|
237 |
+
|
238 |
+
run_folder(model, args, config, device, verbose=True)
|
239 |
+
|
240 |
+
|
241 |
+
if __name__ == "__main__":
|
242 |
+
proc_folder(None)
|
model.py
ADDED
@@ -0,0 +1,714 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import yaml
|
3 |
+
from urllib.parse import quote
|
4 |
+
from pathlib import Path
|
5 |
+
|
6 |
+
# Temel dizin ve checkpoint dizini sabit olarak tanımlanıyor
|
7 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
8 |
+
CHECKPOINT_DIR = os.path.join(BASE_DIR, 'ckpts')
|
9 |
+
|
10 |
+
def conf_edit(config_path, chunk_size, overlap):
|
11 |
+
"""Edits the configuration file with chunk size and overlap."""
|
12 |
+
full_config_path = os.path.join(CHECKPOINT_DIR, os.path.basename(config_path))
|
13 |
+
if not os.path.exists(full_config_path):
|
14 |
+
raise FileNotFoundError(f"Configuration file not found: {full_config_path}")
|
15 |
+
|
16 |
+
with open(full_config_path, 'r') as f:
|
17 |
+
data = yaml.load(f, Loader=yaml.SafeLoader)
|
18 |
+
|
19 |
+
if 'use_amp' not in data.keys():
|
20 |
+
data['training']['use_amp'] = True
|
21 |
+
|
22 |
+
data['audio']['chunk_size'] = chunk_size
|
23 |
+
data['inference']['num_overlap'] = overlap
|
24 |
+
if data['inference']['batch_size'] == 1:
|
25 |
+
data['inference']['batch_size'] = 2
|
26 |
+
|
27 |
+
print(f"Using custom overlap and chunk_size: overlap={overlap}, chunk_size={chunk_size}")
|
28 |
+
with open(full_config_path, 'w') as f:
|
29 |
+
yaml.dump(data, f, default_flow_style=False, sort_keys=False, Dumper=yaml.Dumper)
|
30 |
+
|
31 |
+
def download_file(url):
|
32 |
+
"""Downloads a file from a URL."""
|
33 |
+
import requests
|
34 |
+
encoded_url = quote(url, safe=':/')
|
35 |
+
path = CHECKPOINT_DIR
|
36 |
+
os.makedirs(path, exist_ok=True)
|
37 |
+
filename = os.path.basename(encoded_url)
|
38 |
+
file_path = os.path.join(path, filename)
|
39 |
+
if os.path.exists(file_path):
|
40 |
+
print(f"File '{filename}' already exists at '{path}'.")
|
41 |
+
return
|
42 |
+
try:
|
43 |
+
response = requests.get(url)
|
44 |
+
if response.status_code == 200:
|
45 |
+
with open(file_path, 'wb') as f:
|
46 |
+
f.write(response.content)
|
47 |
+
print(f"File '{filename}' downloaded successfully")
|
48 |
+
else:
|
49 |
+
print(f"Error downloading '{filename}': Status code {response.status_code}")
|
50 |
+
except Exception as e:
|
51 |
+
print(f"Error downloading file '{filename}' from '{url}': {e}")
|
52 |
+
|
53 |
+
# Model konfigurasyonlarını kategorize bir sözlükte tut
|
54 |
+
MODEL_CONFIGS = {
|
55 |
+
"Vocal Models": {
|
56 |
+
'VOCALS-InstVocHQ': {
|
57 |
+
'model_type': 'mdx23c',
|
58 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_vocals_mdx23c.yaml'),
|
59 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_vocals_mdx23c_sdr_10.17.ckpt'),
|
60 |
+
'download_urls': [
|
61 |
+
'https://raw.githubusercontent.com/ZFTurbo/Music-Source-Separation-Training/main/configs/config_vocals_mdx23c.yaml',
|
62 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.0/model_vocals_mdx23c_sdr_10.17.ckpt'
|
63 |
+
],
|
64 |
+
'needs_conf_edit': False
|
65 |
+
},
|
66 |
+
'VOCALS-MelBand-Roformer (by KimberleyJSN)': {
|
67 |
+
'model_type': 'mel_band_roformer',
|
68 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_vocals_mel_band_roformer_kj.yaml'),
|
69 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'MelBandRoformer.ckpt'),
|
70 |
+
'download_urls': [
|
71 |
+
'https://raw.githubusercontent.com/ZFTurbo/Music-Source-Separation-Training/main/configs/KimberleyJensen/config_vocals_mel_band_roformer_kj.yaml',
|
72 |
+
'https://huggingface.co/KimberleyJSN/melbandroformer/resolve/main/MelBandRoformer.ckpt'
|
73 |
+
],
|
74 |
+
'needs_conf_edit': True
|
75 |
+
},
|
76 |
+
'VOCALS-BS-Roformer_1297 (by viperx)': {
|
77 |
+
'model_type': 'bs_roformer',
|
78 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'model_bs_roformer_ep_317_sdr_12.9755.yaml'),
|
79 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_bs_roformer_ep_317_sdr_12.9755.ckpt'),
|
80 |
+
'download_urls': [
|
81 |
+
'https://raw.githubusercontent.com/ZFTurbo/Music-Source-Separation-Training/main/configs/viperx/model_bs_roformer_ep_317_sdr_12.9755.yaml',
|
82 |
+
'https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/model_bs_roformer_ep_317_sdr_12.9755.ckpt'
|
83 |
+
],
|
84 |
+
'needs_conf_edit': True
|
85 |
+
},
|
86 |
+
'VOCALS-BS-Roformer_1296 (by viperx)': {
|
87 |
+
'model_type': 'bs_roformer',
|
88 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'model_bs_roformer_ep_368_sdr_12.9628.yaml'),
|
89 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_bs_roformer_ep_368_sdr_12.9628.ckpt'),
|
90 |
+
'download_urls': [
|
91 |
+
'https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/model_bs_roformer_ep_368_sdr_12.9628.ckpt',
|
92 |
+
'https://raw.githubusercontent.com/TRvlvr/application_data/main/mdx_model_data/mdx_c_configs/model_bs_roformer_ep_368_sdr_12.9628.yaml'
|
93 |
+
],
|
94 |
+
'needs_conf_edit': True
|
95 |
+
},
|
96 |
+
'VOCALS-BS-RoformerLargev1 (by unwa)': {
|
97 |
+
'model_type': 'bs_roformer',
|
98 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_bsrofoL.yaml'),
|
99 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'BS-Roformer_LargeV1.ckpt'),
|
100 |
+
'download_urls': [
|
101 |
+
'https://huggingface.co/jarredou/unwa_bs_roformer/resolve/main/BS-Roformer_LargeV1.ckpt',
|
102 |
+
'https://huggingface.co/jarredou/unwa_bs_roformer/raw/main/config_bsrofoL.yaml'
|
103 |
+
],
|
104 |
+
'needs_conf_edit': True
|
105 |
+
},
|
106 |
+
'VOCALS-Mel-Roformer big beta 4 (by unwa)': {
|
107 |
+
'model_type': 'mel_band_roformer',
|
108 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_melbandroformer_big_beta4.yaml'),
|
109 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'melband_roformer_big_beta4.ckpt'),
|
110 |
+
'download_urls': [
|
111 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-big/resolve/main/melband_roformer_big_beta4.ckpt',
|
112 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-big/raw/main/config_melbandroformer_big_beta4.yaml'
|
113 |
+
],
|
114 |
+
'needs_conf_edit': True
|
115 |
+
},
|
116 |
+
'VOCALS-Melband-Roformer BigBeta5e (by unwa)': {
|
117 |
+
'model_type': 'mel_band_roformer',
|
118 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'big_beta5e.yaml'),
|
119 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'big_beta5e.ckpt'),
|
120 |
+
'download_urls': [
|
121 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-big/resolve/main/big_beta5e.ckpt',
|
122 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-big/resolve/main/big_beta5e.yaml'
|
123 |
+
],
|
124 |
+
'needs_conf_edit': True
|
125 |
+
},
|
126 |
+
'VOCALS-VitLarge23 (by ZFTurbo)': {
|
127 |
+
'model_type': 'segm_models',
|
128 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_vocals_segm_models.yaml'),
|
129 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_vocals_segm_models_sdr_9.77.ckpt'),
|
130 |
+
'download_urls': [
|
131 |
+
'https://raw.githubusercontent.com/ZFTurbo/Music-Source-Separation-Training/refs/heads/main/configs/config_vocals_segm_models.yaml',
|
132 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.0/model_vocals_segm_models_sdr_9.77.ckpt'
|
133 |
+
],
|
134 |
+
'needs_conf_edit': False
|
135 |
+
},
|
136 |
+
'VOCALS-MelBand-Roformer Kim FT (by Unwa)': {
|
137 |
+
'model_type': 'mel_band_roformer',
|
138 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_kimmel_unwa_ft.yaml'),
|
139 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'kimmel_unwa_ft.ckpt'),
|
140 |
+
'download_urls': [
|
141 |
+
'https://huggingface.co/pcunwa/Kim-Mel-Band-Roformer-FT/resolve/main/kimmel_unwa_ft.ckpt',
|
142 |
+
'https://huggingface.co/pcunwa/Kim-Mel-Band-Roformer-FT/resolve/main/config_kimmel_unwa_ft.yaml'
|
143 |
+
],
|
144 |
+
'needs_conf_edit': True
|
145 |
+
},
|
146 |
+
'VOCALS-MelBand-Roformer (by Becruily)': {
|
147 |
+
'model_type': 'mel_band_roformer',
|
148 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_instrumental_becruily.yaml'),
|
149 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'mel_band_roformer_vocals_becruily.ckpt'),
|
150 |
+
'download_urls': [
|
151 |
+
'https://huggingface.co/becruily/mel-band-roformer-vocals/resolve/main/config_vocals_becruily.yaml',
|
152 |
+
'https://huggingface.co/becruily/mel-band-roformer-vocals/resolve/main/mel_band_roformer_vocals_becruily.ckpt'
|
153 |
+
],
|
154 |
+
'needs_conf_edit': True
|
155 |
+
},
|
156 |
+
'VOCALS-Male Female-BS-RoFormer Male Female Beta 7_2889 (by aufr33)': {
|
157 |
+
'model_type': 'bs_roformer',
|
158 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_chorus_male_female_bs_roformer.yaml'),
|
159 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'bs_roformer_male_female_by_aufr33_sdr_7.2889.ckpt'),
|
160 |
+
'download_urls': [
|
161 |
+
'https://huggingface.co/RareSirMix/AIModelRehosting/resolve/main/bs_roformer_male_female_by_aufr33_sdr_7.2889.ckpt',
|
162 |
+
'https://huggingface.co/Sucial/Chorus_Male_Female_BS_Roformer/resolve/main/config_chorus_male_female_bs_roformer.yaml'
|
163 |
+
],
|
164 |
+
'needs_conf_edit': True
|
165 |
+
},
|
166 |
+
'VOCALS-MelBand-Roformer Kim FT 2 (by Unwa)': {
|
167 |
+
'model_type': 'mel_band_roformer',
|
168 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_kimmel_unwa_ft.yaml'),
|
169 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'kimmel_unwa_ft2.ckpt'),
|
170 |
+
'download_urls': [
|
171 |
+
'https://huggingface.co/pcunwa/Kim-Mel-Band-Roformer-FT/resolve/main/config_kimmel_unwa_ft.yaml',
|
172 |
+
'https://huggingface.co/pcunwa/Kim-Mel-Band-Roformer-FT/resolve/main/kimmel_unwa_ft2.ckpt'
|
173 |
+
],
|
174 |
+
'needs_conf_edit': True
|
175 |
+
},
|
176 |
+
'voc_gaboxBSroformer (by Gabox)': {
|
177 |
+
'model_type': 'bs_roformer',
|
178 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'voc_gaboxBSroformer.yaml'),
|
179 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'voc_gaboxBSR.ckpt'),
|
180 |
+
'download_urls': [
|
181 |
+
'https://huggingface.co/GaboxR67/BSRoformerVocTest/resolve/main/voc_gaboxBSroformer.yaml',
|
182 |
+
'https://huggingface.co/GaboxR67/BSRoformerVocTest/resolve/main/voc_gaboxBSR.ckpt'
|
183 |
+
],
|
184 |
+
'needs_conf_edit': True
|
185 |
+
},
|
186 |
+
'voc_gaboxMelReformer (by Gabox)': {
|
187 |
+
'model_type': 'mel_band_roformer',
|
188 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'voc_gabox.yaml'),
|
189 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'voc_gabox.ckpt'),
|
190 |
+
'download_urls': [
|
191 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_gabox.yaml',
|
192 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_gabox.ckpt'
|
193 |
+
],
|
194 |
+
'needs_conf_edit': True
|
195 |
+
},
|
196 |
+
'voc_gaboxMelReformerFV1 (by Gabox)': {
|
197 |
+
'model_type': 'mel_band_roformer',
|
198 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'voc_gabox.yaml'),
|
199 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'voc_gaboxFv1.ckpt'),
|
200 |
+
'download_urls': [
|
201 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_gabox.yaml',
|
202 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_gaboxFv1.ckpt'
|
203 |
+
],
|
204 |
+
'needs_conf_edit': True
|
205 |
+
},
|
206 |
+
'voc_gaboxMelReformerFV2 (by Gabox)': {
|
207 |
+
'model_type': 'mel_band_roformer',
|
208 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'voc_gabox.yaml'),
|
209 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'voc_gaboxFv2.ckpt'),
|
210 |
+
'download_urls': [
|
211 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_gabox.yaml',
|
212 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_gaboxFv2.ckpt'
|
213 |
+
],
|
214 |
+
'needs_conf_edit': True
|
215 |
+
},
|
216 |
+
'VOCALS-MelBand-Roformer Kim FT 2 Blendless (by unwa)': {
|
217 |
+
'model_type': 'mel_band_roformer',
|
218 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_kimmel_unwa_ft.yaml'),
|
219 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'kimmel_unwa_ft2_bleedless.ckpt'),
|
220 |
+
'download_urls': [
|
221 |
+
'https://huggingface.co/pcunwa/Kim-Mel-Band-Roformer-FT/resolve/main/config_kimmel_unwa_ft.yaml',
|
222 |
+
'https://huggingface.co/pcunwa/Kim-Mel-Band-Roformer-FT/resolve/main/kimmel_unwa_ft2_bleedless.ckpt'
|
223 |
+
],
|
224 |
+
'needs_conf_edit': True
|
225 |
+
},
|
226 |
+
'Voc_Fv3 (by Gabox)': {
|
227 |
+
'model_type': 'mel_band_roformer',
|
228 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'voc_gabox.yaml'),
|
229 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'voc_Fv3.ckpt'),
|
230 |
+
'download_urls': [
|
231 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_gabox.yaml',
|
232 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/vocals/voc_Fv3.ckpt'
|
233 |
+
],
|
234 |
+
'needs_conf_edit': True
|
235 |
+
},
|
236 |
+
'FullnessVocalModel (by Amane)': {
|
237 |
+
'model_type': 'mel_band_roformer',
|
238 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config.yaml'),
|
239 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'FullnessVocalModel.ckpt'),
|
240 |
+
'download_urls': [
|
241 |
+
'https://huggingface.co/Aname-Tommy/MelBandRoformers/blob/main/config.yaml',
|
242 |
+
'https://huggingface.co/Aname-Tommy/MelBandRoformers/blob/main/FullnessVocalModel.ckpt'
|
243 |
+
],
|
244 |
+
'needs_conf_edit': True
|
245 |
+
}
|
246 |
+
},
|
247 |
+
"Instrumental Models": {
|
248 |
+
'INST-Mel-Roformer v1 (by unwa)': {
|
249 |
+
'model_type': 'mel_band_roformer',
|
250 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_melbandroformer_inst.yaml'),
|
251 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'melband_roformer_inst_v1.ckpt'),
|
252 |
+
'download_urls': [
|
253 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-Inst/resolve/main/melband_roformer_inst_v1.ckpt',
|
254 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-Inst/raw/main/config_melbandroformer_inst.yaml'
|
255 |
+
],
|
256 |
+
'needs_conf_edit': True
|
257 |
+
},
|
258 |
+
'INST-Mel-Roformer v2 (by unwa)': {
|
259 |
+
'model_type': 'mel_band_roformer',
|
260 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_melbandroformer_inst_v2.yaml'),
|
261 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'melband_roformer_inst_v2.ckpt'),
|
262 |
+
'download_urls': [
|
263 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-Inst/resolve/main/melband_roformer_inst_v2.ckpt',
|
264 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-Inst/raw/main/config_melbandroformer_inst_v2.yaml'
|
265 |
+
],
|
266 |
+
'needs_conf_edit': True
|
267 |
+
},
|
268 |
+
'INST-VOC-Mel-Roformer a.k.a. duality (by unwa)': {
|
269 |
+
'model_type': 'mel_band_roformer',
|
270 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_melbandroformer_instvoc_duality.yaml'),
|
271 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'melband_roformer_instvoc_duality_v1.ckpt'),
|
272 |
+
'download_urls': [
|
273 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-InstVoc-Duality/resolve/main/melband_roformer_instvoc_duality_v1.ckpt',
|
274 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-InstVoc-Duality/raw/main/config_melbandroformer_instvoc_duality.yaml'
|
275 |
+
],
|
276 |
+
'needs_conf_edit': True
|
277 |
+
},
|
278 |
+
'INST-VOC-Mel-Roformer a.k.a. duality v2 (by unwa)': {
|
279 |
+
'model_type': 'mel_band_roformer',
|
280 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_melbandroformer_instvoc_duality.yaml'),
|
281 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'melband_roformer_instvox_duality_v2.ckpt'),
|
282 |
+
'download_urls': [
|
283 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-InstVoc-Duality/resolve/main/melband_roformer_instvox_duality_v2.ckpt',
|
284 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-InstVoc-Duality/raw/main/config_melbandroformer_instvoc_duality.yaml'
|
285 |
+
],
|
286 |
+
'needs_conf_edit': True
|
287 |
+
},
|
288 |
+
'INST-MelBand-Roformer (by Becruily)': {
|
289 |
+
'model_type': 'mel_band_roformer',
|
290 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_instrumental_becruily.yaml'),
|
291 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'mel_band_roformer_instrumental_becruily.ckpt'),
|
292 |
+
'download_urls': [
|
293 |
+
'https://huggingface.co/becruily/mel-band-roformer-instrumental/resolve/main/config_instrumental_becruily.yaml',
|
294 |
+
'https://huggingface.co/becruily/mel-band-roformer-instrumental/resolve/main/mel_band_roformer_instrumental_becruily.ckpt'
|
295 |
+
],
|
296 |
+
'needs_conf_edit': True
|
297 |
+
},
|
298 |
+
'inst_v1e (by unwa)': {
|
299 |
+
'model_type': 'mel_band_roformer',
|
300 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_melbandroformer_inst.yaml'),
|
301 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_v1e.ckpt'),
|
302 |
+
'download_urls': [
|
303 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-Inst/resolve/main/inst_v1e.ckpt',
|
304 |
+
'https://huggingface.co/pcunwa/Mel-Band-Roformer-Inst/resolve/main/config_melbandroformer_inst.yaml'
|
305 |
+
],
|
306 |
+
'needs_conf_edit': True
|
307 |
+
},
|
308 |
+
'inst_gabox (by Gabox)': {
|
309 |
+
'model_type': 'mel_band_roformer',
|
310 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
311 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_gabox.ckpt'),
|
312 |
+
'download_urls': [
|
313 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
314 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.ckpt'
|
315 |
+
],
|
316 |
+
'needs_conf_edit': True
|
317 |
+
},
|
318 |
+
'inst_gaboxBV1 (by Gabox)': {
|
319 |
+
'model_type': 'mel_band_roformer',
|
320 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
321 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_gaboxBv1.ckpt'),
|
322 |
+
'download_urls': [
|
323 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
324 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gaboxBv1.ckpt'
|
325 |
+
],
|
326 |
+
'needs_conf_edit': True
|
327 |
+
},
|
328 |
+
'inst_gaboxBV2 (by Gabox)': {
|
329 |
+
'model_type': 'mel_band_roformer',
|
330 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
331 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_gaboxBv2.ckpt'),
|
332 |
+
'download_urls': [
|
333 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
334 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gaboxBv2.ckpt'
|
335 |
+
],
|
336 |
+
'needs_conf_edit': True
|
337 |
+
},
|
338 |
+
'inst_gaboxBFV1 (by Gabox)': {
|
339 |
+
'model_type': 'mel_band_roformer',
|
340 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
341 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'gaboxFv1.ckpt'),
|
342 |
+
'download_urls': [
|
343 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
344 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gaboxFv1.ckpt'
|
345 |
+
],
|
346 |
+
'needs_conf_edit': True
|
347 |
+
},
|
348 |
+
'inst_gaboxFV2 (by Gabox)': {
|
349 |
+
'model_type': 'mel_band_roformer',
|
350 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
351 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_gaboxFv2.ckpt'),
|
352 |
+
'download_urls': [
|
353 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
354 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gaboxFv2.ckpt'
|
355 |
+
],
|
356 |
+
'needs_conf_edit': True
|
357 |
+
},
|
358 |
+
'inst_Fv3 (by Gabox)': {
|
359 |
+
'model_type': 'mel_band_roformer',
|
360 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
361 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_gaboxFv3.ckpt'),
|
362 |
+
'download_urls': [
|
363 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
364 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gaboxFv3.ckpt'
|
365 |
+
],
|
366 |
+
'needs_conf_edit': True
|
367 |
+
},
|
368 |
+
'Intrumental_Gabox (by Gabox)': {
|
369 |
+
'model_type': 'mel_band_roformer',
|
370 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
371 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'intrumental_gabox.ckpt'),
|
372 |
+
'download_urls': [
|
373 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
374 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/intrumental_gabox.ckpt'
|
375 |
+
],
|
376 |
+
'needs_conf_edit': True
|
377 |
+
},
|
378 |
+
'inst_Fv4Noise (by Gabox)': {
|
379 |
+
'model_type': 'mel_band_roformer',
|
380 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
381 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_Fv4Noise.ckpt'),
|
382 |
+
'download_urls': [
|
383 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
384 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_Fv4Noise.ckpt'
|
385 |
+
],
|
386 |
+
'needs_conf_edit': True
|
387 |
+
},
|
388 |
+
'INSTV5 (by Gabox)': {
|
389 |
+
'model_type': 'mel_band_roformer',
|
390 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
391 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'INSTV5.ckpt'),
|
392 |
+
'download_urls': [
|
393 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
394 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/INSTV5.ckpt'
|
395 |
+
],
|
396 |
+
'needs_conf_edit': True
|
397 |
+
},
|
398 |
+
'inst_gaboxFV1 (by Gabox)': {
|
399 |
+
'model_type': 'mel_band_roformer',
|
400 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
401 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'inst_gaboxFv1.ckpt'),
|
402 |
+
'download_urls': [
|
403 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
404 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gaboxFv1.ckpt'
|
405 |
+
],
|
406 |
+
'needs_conf_edit': True
|
407 |
+
},
|
408 |
+
'inst_gaboxFV6 (by Gabox)': {
|
409 |
+
'model_type': 'mel_band_roformer',
|
410 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
411 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'INSTV6.ckpt'),
|
412 |
+
'download_urls': [
|
413 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
414 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/INSTV6.ckpt'
|
415 |
+
],
|
416 |
+
'needs_conf_edit': True
|
417 |
+
},
|
418 |
+
'INSTV5N (by Gabox)': {
|
419 |
+
'model_type': 'mel_band_roformer',
|
420 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
421 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'INSTV5N.ckpt'),
|
422 |
+
'download_urls': [
|
423 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
424 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/INSTV5N.ckpt'
|
425 |
+
],
|
426 |
+
'needs_conf_edit': True
|
427 |
+
},
|
428 |
+
'INSTV6N (by Gabox)': {
|
429 |
+
'model_type': 'mel_band_roformer',
|
430 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
431 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'INSTV6N.ckpt'),
|
432 |
+
'download_urls': [
|
433 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
434 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/INSTV6N.ckpt'
|
435 |
+
],
|
436 |
+
'needs_conf_edit': True
|
437 |
+
},
|
438 |
+
'Inst_GaboxV7 (by Gabox)': {
|
439 |
+
'model_type': 'mel_band_roformer',
|
440 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'inst_gabox.yaml'),
|
441 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'Inst_GaboxV7.ckpt'),
|
442 |
+
'download_urls': [
|
443 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/inst_gabox.yaml',
|
444 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/Inst_GaboxV7.ckpt'
|
445 |
+
],
|
446 |
+
'needs_conf_edit': True
|
447 |
+
}
|
448 |
+
},
|
449 |
+
"4-Stem Models": {
|
450 |
+
'4STEMS-SCNet_MUSDB18 (by starrytong)': {
|
451 |
+
'model_type': 'scnet',
|
452 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_musdb18_scnet.yaml'),
|
453 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'scnet_checkpoint_musdb18.ckpt'),
|
454 |
+
'download_urls': [
|
455 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v.1.0.6/config_musdb18_scnet.yaml',
|
456 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v.1.0.6/scnet_checkpoint_musdb18.ckpt'
|
457 |
+
],
|
458 |
+
'needs_conf_edit': False
|
459 |
+
},
|
460 |
+
'4STEMS-SCNet_XL_MUSDB18 (by ZFTurbo)': {
|
461 |
+
'model_type': 'scnet',
|
462 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_musdb18_scnet_xl.yaml'),
|
463 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_scnet_ep_54_sdr_9.8051.ckpt'),
|
464 |
+
'download_urls': [
|
465 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.13/config_musdb18_scnet_xl.yaml',
|
466 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.13/model_scnet_ep_54_sdr_9.8051.ckpt'
|
467 |
+
],
|
468 |
+
'needs_conf_edit': True
|
469 |
+
},
|
470 |
+
'4STEMS-SCNet_Large (by starrytong)': {
|
471 |
+
'model_type': 'scnet',
|
472 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_musdb18_scnet_large_starrytong.yaml'),
|
473 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'SCNet-large_starrytong_fixed.ckpt'),
|
474 |
+
'download_urls': [
|
475 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.9/config_musdb18_scnet_large_starrytong.yaml',
|
476 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.9/SCNet-large_starrytong_fixed.ckpt'
|
477 |
+
],
|
478 |
+
'needs_conf_edit': True
|
479 |
+
},
|
480 |
+
'4STEMS-BS-Roformer_MUSDB18 (by ZFTurbo)': {
|
481 |
+
'model_type': 'bs_roformer',
|
482 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_bs_roformer_384_8_2_485100.yaml'),
|
483 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_bs_roformer_ep_17_sdr_9.6568.ckpt'),
|
484 |
+
'download_urls': [
|
485 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.12/config_bs_roformer_384_8_2_485100.yaml',
|
486 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v1.0.12/model_bs_roformer_ep_17_sdr_9.6568.ckpt'
|
487 |
+
],
|
488 |
+
'needs_conf_edit': True
|
489 |
+
},
|
490 |
+
'MelBandRoformer4StemFTLarge (SYH99999)': {
|
491 |
+
'model_type': 'mel_band_roformer',
|
492 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config.yaml'),
|
493 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'MelBandRoformer4StemFTLarge.ckpt'),
|
494 |
+
'download_urls': [
|
495 |
+
'https://huggingface.co/SYH99999/MelBandRoformer4StemFTLarge/resolve/main/config.yaml',
|
496 |
+
'https://huggingface.co/SYH99999/MelBandRoformer4StemFTLarge/resolve/main/MelBandRoformer4StemFTLarge.ckpt'
|
497 |
+
],
|
498 |
+
'needs_conf_edit': True
|
499 |
+
}
|
500 |
+
},
|
501 |
+
"Denoise Models": {
|
502 |
+
'DENOISE-MelBand-Roformer-1 (by aufr33)': {
|
503 |
+
'model_type': 'mel_band_roformer',
|
504 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'model_mel_band_roformer_denoise.yaml'),
|
505 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'denoise_mel_band_roformer_aufr33_sdr_27.9959.ckpt'),
|
506 |
+
'download_urls': [
|
507 |
+
'https://huggingface.co/jarredou/aufr33_MelBand_Denoise/resolve/main/denoise_mel_band_roformer_aufr33_sdr_27.9959.ckpt',
|
508 |
+
'https://huggingface.co/jarredou/aufr33_MelBand_Denoise/resolve/main/model_mel_band_roformer_denoise.yaml'
|
509 |
+
],
|
510 |
+
'needs_conf_edit': True
|
511 |
+
},
|
512 |
+
'DENOISE-MelBand-Roformer-2 (by aufr33)': {
|
513 |
+
'model_type': 'mel_band_roformer',
|
514 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'model_mel_band_roformer_denoise.yaml'),
|
515 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'denoise_mel_band_roformer_aufr33_aggr_sdr_27.9768.ckpt'),
|
516 |
+
'download_urls': [
|
517 |
+
'https://huggingface.co/jarredou/aufr33_MelBand_Denoise/resolve/main/denoise_mel_band_roformer_aufr33_aggr_sdr_27.9768.ckpt',
|
518 |
+
'https://huggingface.co/jarredou/aufr33_MelBand_Denoise/resolve/main/model_mel_band_roformer_denoise.yaml'
|
519 |
+
],
|
520 |
+
'needs_conf_edit': True
|
521 |
+
},
|
522 |
+
'denoisedebleed (by Gabox)': {
|
523 |
+
'model_type': 'mel_band_roformer',
|
524 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'model_mel_band_roformer_denoise.yaml'),
|
525 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'denoisedebleed.ckpt'),
|
526 |
+
'download_urls': [
|
527 |
+
'https://huggingface.co/poiqazwsx/melband-roformer-denoise/resolve/main/model_mel_band_roformer_denoise.yaml',
|
528 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/resolve/main/melbandroformers/instrumental/denoisedebleed.ckpt'
|
529 |
+
],
|
530 |
+
'needs_conf_edit': True
|
531 |
+
}
|
532 |
+
},
|
533 |
+
"Dereverb Models": {
|
534 |
+
'DE-REVERB-MDX23C (by aufr33 & jarredou)': {
|
535 |
+
'model_type': 'mdx23c',
|
536 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_dereverb_mdx23c.yaml'),
|
537 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'dereverb_mdx23c_sdr_6.9096.ckpt'),
|
538 |
+
'download_urls': [
|
539 |
+
'https://huggingface.co/jarredou/aufr33_jarredou_MDXv3_DeReverb/resolve/main/dereverb_mdx23c_sdr_6.9096.ckpt',
|
540 |
+
'https://huggingface.co/jarredou/aufr33_jarredou_MDXv3_DeReverb/resolve/main/config_dereverb_mdx23c.yaml'
|
541 |
+
],
|
542 |
+
'needs_conf_edit': False
|
543 |
+
},
|
544 |
+
'DE-REVERB-MelBand-Roformer aggr./v2/19.1729 (by anvuew)': {
|
545 |
+
'model_type': 'mel_band_roformer',
|
546 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_anvuew.yaml'),
|
547 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_anvuew_sdr_19.1729.ckpt'),
|
548 |
+
'download_urls': [
|
549 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_anvuew_sdr_19.1729.ckpt',
|
550 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_anvuew.yaml'
|
551 |
+
],
|
552 |
+
'needs_conf_edit': True
|
553 |
+
},
|
554 |
+
'DE-REVERB-Echo-MelBand-Roformer (by Sucial)': {
|
555 |
+
'model_type': 'mel_band_roformer',
|
556 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_dereverb-echo_mel_band_roformer.yaml'),
|
557 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'dereverb-echo_mel_band_roformer_sdr_10.0169.ckpt'),
|
558 |
+
'download_urls': [
|
559 |
+
'https://huggingface.co/Sucial/Dereverb-Echo_Mel_Band_Roformer/resolve/main/dereverb-echo_mel_band_roformer_sdr_10.0169.ckpt',
|
560 |
+
'https://huggingface.co/Sucial/Dereverb-Echo_Mel_Band_Roformer/resolve/main/config_dereverb-echo_mel_band_roformer.yaml'
|
561 |
+
],
|
562 |
+
'needs_conf_edit': True
|
563 |
+
},
|
564 |
+
'dereverb_mel_band_roformer_less_aggressive_anvuew': {
|
565 |
+
'model_type': 'mel_band_roformer',
|
566 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_anvuew.yaml'),
|
567 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_less_aggressive_anvuew_sdr_18.8050.ckpt'),
|
568 |
+
'download_urls': [
|
569 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_anvuew.yaml',
|
570 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_less_aggressive_anvuew_sdr_18.8050.ckpt'
|
571 |
+
],
|
572 |
+
'needs_conf_edit': True
|
573 |
+
},
|
574 |
+
'dereverb_mel_band_roformer_anvuew': {
|
575 |
+
'model_type': 'mel_band_roformer',
|
576 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_anvuew.yaml'),
|
577 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_anvuew_sdr_19.1729.ckpt'),
|
578 |
+
'download_urls': [
|
579 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_anvuew.yaml',
|
580 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_anvuew_sdr_19.1729.ckpt'
|
581 |
+
],
|
582 |
+
'needs_conf_edit': True
|
583 |
+
},
|
584 |
+
'dereverb_mel_band_roformer_mono (by anvuew)': {
|
585 |
+
'model_type': 'mel_band_roformer',
|
586 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_anvuew.yaml'),
|
587 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'dereverb_mel_band_roformer_mono_anvuew_sdr_20.4029.ckpt'),
|
588 |
+
'download_urls': [
|
589 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_anvuew.yaml',
|
590 |
+
'https://huggingface.co/anvuew/dereverb_mel_band_roformer/resolve/main/dereverb_mel_band_roformer_mono_anvuew_sdr_20.4029.ckpt'
|
591 |
+
],
|
592 |
+
'needs_conf_edit': True
|
593 |
+
}
|
594 |
+
},
|
595 |
+
"Other Models": {
|
596 |
+
'KARAOKE-MelBand-Roformer (by aufr33 & viperx)': {
|
597 |
+
'model_type': 'mel_band_roformer',
|
598 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_mel_band_roformer_karaoke.yaml'),
|
599 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt'),
|
600 |
+
'download_urls': [
|
601 |
+
'https://huggingface.co/jarredou/aufr33-viperx-karaoke-melroformer-model/resolve/main/mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt',
|
602 |
+
'https://huggingface.co/jarredou/aufr33-viperx-karaoke-melroformer-model/resolve/main/config_mel_band_roformer_karaoke.yaml'
|
603 |
+
],
|
604 |
+
'needs_conf_edit': True
|
605 |
+
},
|
606 |
+
'OTHER-BS-Roformer_1053 (by viperx)': {
|
607 |
+
'model_type': 'bs_roformer',
|
608 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'model_bs_roformer_ep_937_sdr_10.5309.yaml'),
|
609 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_bs_roformer_ep_937_sdr_10.5309.ckpt'),
|
610 |
+
'download_urls': [
|
611 |
+
'https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/model_bs_roformer_ep_937_sdr_10.5309.ckpt',
|
612 |
+
'https://raw.githubusercontent.com/TRvlvr/application_data/main/mdx_model_data/mdx_c_configs/model_bs_roformer_ep_937_sdr_10.5309.yaml'
|
613 |
+
],
|
614 |
+
'needs_conf_edit': True
|
615 |
+
},
|
616 |
+
'CROWD-REMOVAL-MelBand-Roformer (by aufr33)': {
|
617 |
+
'model_type': 'mel_band_roformer',
|
618 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'model_mel_band_roformer_crowd.yaml'),
|
619 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'mel_band_roformer_crowd_aufr33_viperx_sdr_8.7144.ckpt'),
|
620 |
+
'download_urls': [
|
621 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v.1.0.4/mel_band_roformer_crowd_aufr33_viperx_sdr_8.7144.ckpt',
|
622 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v.1.0.4/model_mel_band_roformer_crowd.yaml'
|
623 |
+
],
|
624 |
+
'needs_conf_edit': True
|
625 |
+
},
|
626 |
+
'CINEMATIC-BandIt_Plus (by kwatcharasupat)': {
|
627 |
+
'model_type': 'bandit',
|
628 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_dnr_bandit_bsrnn_multi_mus64.yaml'),
|
629 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model_bandit_plus_dnr_sdr_11.47.chpt'),
|
630 |
+
'download_urls': [
|
631 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v.1.0.3/config_dnr_bandit_bsrnn_multi_mus64.yaml',
|
632 |
+
'https://github.com/ZFTurbo/Music-Source-Separation-Training/releases/download/v.1.0.3/model_bandit_plus_dnr_sdr_11.47.chpt'
|
633 |
+
],
|
634 |
+
'needs_conf_edit': False
|
635 |
+
},
|
636 |
+
'DRUMSEP-MDX23C_DrumSep_6stem (by aufr33 & jarredou)': {
|
637 |
+
'model_type': 'mdx23c',
|
638 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'aufr33-jarredou_DrumSep_model_mdx23c_ep_141_sdr_10.8059.yaml'),
|
639 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'aufr33-jarredou_DrumSep_model_mdx23c_ep_141_sdr_10.8059.ckpt'),
|
640 |
+
'download_urls': [
|
641 |
+
'https://github.com/jarredou/models/releases/download/aufr33-jarredou_MDX23C_DrumSep_model_v0.1/aufr33-jarredou_DrumSep_model_mdx23c_ep_141_sdr_10.8059.ckpt',
|
642 |
+
'https://github.com/jarredou/models/releases/download/aufr33-jarredou_MDX23C_DrumSep_model_v0.1/aufr33-jarredou_DrumSep_model_mdx23c_ep_141_sdr_10.8059.yaml'
|
643 |
+
],
|
644 |
+
'needs_conf_edit': False
|
645 |
+
},
|
646 |
+
'bleed_suppressor_v1 (by unwa)': {
|
647 |
+
'model_type': 'mel_band_roformer',
|
648 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_bleed_suppressor_v1.yaml'),
|
649 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'bleed_suppressor_v1.ckpt'),
|
650 |
+
'download_urls': [
|
651 |
+
'https://huggingface.co/ASesYusuf1/MODELS/resolve/main/bleed_suppressor_v1.ckpt',
|
652 |
+
'https://huggingface.co/ASesYusuf1/MODELS/resolve/main/config_bleed_suppressor_v1.yaml'
|
653 |
+
],
|
654 |
+
'needs_conf_edit': True
|
655 |
+
},
|
656 |
+
'SYH99999/MelBandRoformerSYHFTB1_Model1 (by Amane)': {
|
657 |
+
'model_type': 'mel_band_roformer',
|
658 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config.yaml'),
|
659 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model.ckpt'),
|
660 |
+
'download_urls': [
|
661 |
+
'https://huggingface.co/SYH99999/MelBandRoformerSYHFTB1/resolve/main/config.yaml',
|
662 |
+
'https://huggingface.co/SYH99999/MelBandRoformerSYHFTB1/resolve/main/model.ckpt'
|
663 |
+
],
|
664 |
+
'needs_conf_edit': True
|
665 |
+
},
|
666 |
+
'SYH99999/MelBandRoformerSYHFTB1_Model2 (by Amane)': {
|
667 |
+
'model_type': 'mel_band_roformer',
|
668 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config.yaml'),
|
669 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model2.ckpt'),
|
670 |
+
'download_urls': [
|
671 |
+
'https://huggingface.co/SYH99999/MelBandRoformerSYHFTB1/resolve/main/config.yaml',
|
672 |
+
'https://huggingface.co/SYH99999/MelBandRoformerSYHFTB1/resolve/main/model2.ckpt'
|
673 |
+
],
|
674 |
+
'needs_conf_edit': True
|
675 |
+
},
|
676 |
+
'SYH99999/MelBandRoformerSYHFTB1_Model3 (by Amane)': {
|
677 |
+
'model_type': 'mel_band_roformer',
|
678 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config.yaml'),
|
679 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'model3.ckpt'),
|
680 |
+
'download_urls': [
|
681 |
+
'https://huggingface.co/SYH99999/MelBandRoformerSYHFTB1/resolve/main/config.yaml',
|
682 |
+
'https://huggingface.co/SYH99999/MelBandRoformerSYHFTB1/resolve/main/model3.ckpt'
|
683 |
+
],
|
684 |
+
'needs_conf_edit': True
|
685 |
+
},
|
686 |
+
'KaraokeGabox': {
|
687 |
+
'model_type': 'mel_band_roformer',
|
688 |
+
'config_path': os.path.join(CHECKPOINT_DIR, 'config_mel_band_roformer_karaoke.yaml'),
|
689 |
+
'start_check_point': os.path.join(CHECKPOINT_DIR, 'KaraokeGabox.ckpt'),
|
690 |
+
'download_urls': [
|
691 |
+
'https://github.com/deton24/Colab-for-new-MDX_UVR_models/releases/download/v1.0.0/config_mel_band_roformer_karaoke.yaml',
|
692 |
+
'https://huggingface.co/GaboxR67/MelBandRoformers/blob/main/melbandroformers/experimental/KaraokeGabox.ckpt'
|
693 |
+
],
|
694 |
+
'needs_conf_edit': True
|
695 |
+
}
|
696 |
+
}
|
697 |
+
}
|
698 |
+
|
699 |
+
def get_model_config(clean_model=None, chunk_size=None, overlap=None):
|
700 |
+
"""Returns model type, config path, and checkpoint path for a given model name, downloading files if needed."""
|
701 |
+
if clean_model is None:
|
702 |
+
return {model_name for category in MODEL_CONFIGS.values() for model_name in category.keys()}
|
703 |
+
|
704 |
+
for category in MODEL_CONFIGS.values():
|
705 |
+
if clean_model in category:
|
706 |
+
config = category[clean_model]
|
707 |
+
for url in config['download_urls']:
|
708 |
+
download_file(url)
|
709 |
+
if config['needs_conf_edit'] and chunk_size is not None and overlap is not None:
|
710 |
+
conf_edit(config['config_path'], chunk_size, overlap)
|
711 |
+
return config['model_type'], config['config_path'], config['start_check_point']
|
712 |
+
return "", "", ""
|
713 |
+
|
714 |
+
get_model_config.keys = lambda: {model_name for category in MODEL_CONFIGS.values() for model_name in category.keys()}
|
processing.py
ADDED
@@ -0,0 +1,320 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import glob
|
3 |
+
import subprocess
|
4 |
+
import time
|
5 |
+
import gc
|
6 |
+
import shutil
|
7 |
+
import sys
|
8 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
9 |
+
sys.path.append(current_dir)
|
10 |
+
|
11 |
+
from datetime import datetime
|
12 |
+
from helpers import INPUT_DIR, OLD_OUTPUT_DIR, ENSEMBLE_DIR, AUTO_ENSEMBLE_TEMP, move_old_files, clear_directory, BASE_DIR
|
13 |
+
from model import get_model_config
|
14 |
+
import torch
|
15 |
+
import yaml
|
16 |
+
import gradio as gr
|
17 |
+
import threading
|
18 |
+
import random
|
19 |
+
import librosa
|
20 |
+
import soundfile as sf
|
21 |
+
import numpy as np
|
22 |
+
import requests
|
23 |
+
import json
|
24 |
+
import locale
|
25 |
+
import re
|
26 |
+
import psutil
|
27 |
+
import concurrent.futures
|
28 |
+
from tqdm import tqdm
|
29 |
+
from google.oauth2.credentials import Credentials
|
30 |
+
import tempfile
|
31 |
+
from urllib.parse import urlparse, quote
|
32 |
+
import gdown
|
33 |
+
from clean_model import clean_model_name, shorten_filename, clean_filename
|
34 |
+
|
35 |
+
import warnings
|
36 |
+
warnings.filterwarnings("ignore")
|
37 |
+
|
38 |
+
# BASE_DIR'i dinamik olarak güncel dizine ayarla
|
39 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # processing.py'nin bulunduğu dizin
|
40 |
+
INFERENCE_PATH = os.path.join(BASE_DIR, "inference.py") # inference.py'nin tam yolu
|
41 |
+
OUTPUT_DIR = os.path.join(BASE_DIR, "output") # Çıkış dizini BASE_DIR/output olarak güncellendi
|
42 |
+
AUTO_ENSEMBLE_OUTPUT = os.path.join(BASE_DIR, "ensemble_output") # Ensemble çıkış dizini
|
43 |
+
|
44 |
+
def extract_model_name(full_model_string):
|
45 |
+
"""Extracts the clean model name from a string."""
|
46 |
+
if not full_model_string:
|
47 |
+
return ""
|
48 |
+
cleaned = str(full_model_string)
|
49 |
+
if ' - ' in cleaned:
|
50 |
+
cleaned = cleaned.split(' - ')[0]
|
51 |
+
emoji_prefixes = ['✅ ', '👥 ', '🗣️ ', '🏛️ ', '🔇 ', '🔉 ', '🎬 ', '🎼 ', '✅(?) ']
|
52 |
+
for prefix in emoji_prefixes:
|
53 |
+
if cleaned.startswith(prefix):
|
54 |
+
cleaned = cleaned[len(prefix):]
|
55 |
+
return cleaned.strip()
|
56 |
+
|
57 |
+
def run_command_and_process_files(model_type, config_path, start_check_point, INPUT_DIR, OUTPUT_DIR, extract_instrumental, use_tta, demud_phaseremix_inst, clean_model):
|
58 |
+
try:
|
59 |
+
# inference.py'nin tam yolunu kullan
|
60 |
+
cmd_parts = [
|
61 |
+
"python", INFERENCE_PATH,
|
62 |
+
"--model_type", model_type,
|
63 |
+
"--config_path", config_path,
|
64 |
+
"--start_check_point", start_check_point,
|
65 |
+
"--input_folder", INPUT_DIR,
|
66 |
+
"--store_dir", OUTPUT_DIR,
|
67 |
+
]
|
68 |
+
if extract_instrumental:
|
69 |
+
cmd_parts.append("--extract_instrumental")
|
70 |
+
if use_tta:
|
71 |
+
cmd_parts.append("--use_tta")
|
72 |
+
if demud_phaseremix_inst:
|
73 |
+
cmd_parts.append("--demud_phaseremix_inst")
|
74 |
+
|
75 |
+
process = subprocess.Popen(
|
76 |
+
cmd_parts,
|
77 |
+
cwd=BASE_DIR, # Çalışma dizini olarak BASE_DIR kullan
|
78 |
+
stdout=subprocess.PIPE,
|
79 |
+
stderr=subprocess.PIPE,
|
80 |
+
text=True,
|
81 |
+
bufsize=1,
|
82 |
+
universal_newlines=True
|
83 |
+
)
|
84 |
+
|
85 |
+
for line in process.stdout:
|
86 |
+
print(line.strip())
|
87 |
+
for line in process.stderr:
|
88 |
+
print(line.strip())
|
89 |
+
|
90 |
+
process.wait()
|
91 |
+
|
92 |
+
filename_model = clean_model_name(clean_model)
|
93 |
+
|
94 |
+
def rename_files_with_model(folder, filename_model):
|
95 |
+
for filename in sorted(os.listdir(folder)):
|
96 |
+
file_path = os.path.join(folder, filename)
|
97 |
+
if not any(filename.lower().endswith(ext) for ext in ['.mp3', '.wav', '.flac', '.aac', '.ogg', '.m4a']):
|
98 |
+
continue
|
99 |
+
base, ext = os.path.splitext(filename)
|
100 |
+
clean_base = base.strip('_- ')
|
101 |
+
new_filename = f"{clean_base}_{filename_model}{ext}"
|
102 |
+
new_file_path = os.path.join(folder, new_filename)
|
103 |
+
os.rename(file_path, new_file_path)
|
104 |
+
|
105 |
+
rename_files_with_model(OUTPUT_DIR, filename_model)
|
106 |
+
|
107 |
+
output_files = os.listdir(OUTPUT_DIR)
|
108 |
+
|
109 |
+
def find_file(keyword):
|
110 |
+
matching_files = [
|
111 |
+
os.path.join(OUTPUT_DIR, f) for f in output_files
|
112 |
+
if keyword in f.lower()
|
113 |
+
]
|
114 |
+
return matching_files[0] if matching_files else None
|
115 |
+
|
116 |
+
vocal_file = find_file('vocals')
|
117 |
+
instrumental_file = find_file('instrumental')
|
118 |
+
phaseremix_file = find_file('phaseremix')
|
119 |
+
drum_file = find_file('drum')
|
120 |
+
bass_file = find_file('bass')
|
121 |
+
other_file = find_file('other')
|
122 |
+
effects_file = find_file('effects')
|
123 |
+
speech_file = find_file('speech')
|
124 |
+
music_file = find_file('music')
|
125 |
+
dry_file = find_file('dry')
|
126 |
+
male_file = find_file('male')
|
127 |
+
female_file = find_file('female')
|
128 |
+
bleed_file = find_file('bleed')
|
129 |
+
karaoke_file = find_file('karaoke')
|
130 |
+
|
131 |
+
return (
|
132 |
+
vocal_file or None,
|
133 |
+
instrumental_file or None,
|
134 |
+
phaseremix_file or None,
|
135 |
+
drum_file or None,
|
136 |
+
bass_file or None,
|
137 |
+
other_file or None,
|
138 |
+
effects_file or None,
|
139 |
+
speech_file or None,
|
140 |
+
music_file or None,
|
141 |
+
dry_file or None,
|
142 |
+
male_file or None,
|
143 |
+
female_file or None,
|
144 |
+
bleed_file or None,
|
145 |
+
karaoke_file or None
|
146 |
+
)
|
147 |
+
|
148 |
+
except Exception as e:
|
149 |
+
print(f"An error occurred: {e}")
|
150 |
+
return (None,) * 14
|
151 |
+
|
152 |
+
clear_directory(INPUT_DIR)
|
153 |
+
|
154 |
+
def process_audio(input_audio_file, model, chunk_size, overlap, export_format, use_tta, demud_phaseremix_inst, extract_instrumental, clean_model, *args, **kwargs):
|
155 |
+
"""Processes audio using the specified model and returns separated stems."""
|
156 |
+
if input_audio_file is not None:
|
157 |
+
audio_path = input_audio_file.name
|
158 |
+
else:
|
159 |
+
existing_files = os.listdir(INPUT_DIR)
|
160 |
+
if existing_files:
|
161 |
+
audio_path = os.path.join(INPUT_DIR, existing_files[0])
|
162 |
+
else:
|
163 |
+
print("No audio file provided and no existing file in input directory.")
|
164 |
+
return [None] * 14
|
165 |
+
|
166 |
+
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
167 |
+
os.makedirs(OLD_OUTPUT_DIR, exist_ok=True)
|
168 |
+
move_old_files(OUTPUT_DIR)
|
169 |
+
|
170 |
+
clean_model_name_full = extract_model_name(model)
|
171 |
+
print(f"Processing audio from: {audio_path} using model: {clean_model_name_full}")
|
172 |
+
|
173 |
+
model_type, config_path, start_check_point = get_model_config(clean_model_name_full, chunk_size, overlap)
|
174 |
+
|
175 |
+
outputs = run_command_and_process_files(
|
176 |
+
model_type=model_type,
|
177 |
+
config_path=config_path,
|
178 |
+
start_check_point=start_check_point,
|
179 |
+
INPUT_DIR=INPUT_DIR,
|
180 |
+
OUTPUT_DIR=OUTPUT_DIR,
|
181 |
+
extract_instrumental=extract_instrumental,
|
182 |
+
use_tta=use_tta,
|
183 |
+
demud_phaseremix_inst=demud_phaseremix_inst,
|
184 |
+
clean_model=clean_model_name_full
|
185 |
+
)
|
186 |
+
|
187 |
+
return outputs
|
188 |
+
|
189 |
+
def ensemble_audio_fn(files, method, weights):
|
190 |
+
try:
|
191 |
+
if len(files) < 2:
|
192 |
+
return None, "⚠️ Minimum 2 files required"
|
193 |
+
|
194 |
+
valid_files = [f for f in files if os.path.exists(f)]
|
195 |
+
if len(valid_files) < 2:
|
196 |
+
return None, "❌ Valid files not found"
|
197 |
+
|
198 |
+
output_dir = os.path.join(BASE_DIR, "ensembles") # BASE_DIR üzerinden dinamik
|
199 |
+
os.makedirs(output_dir, exist_ok=True)
|
200 |
+
|
201 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
202 |
+
output_path = f"{output_dir}/ensemble_{timestamp}.wav"
|
203 |
+
|
204 |
+
ensemble_args = [
|
205 |
+
"--files", *valid_files,
|
206 |
+
"--type", method.lower().replace(' ', '_'),
|
207 |
+
"--output", output_path
|
208 |
+
]
|
209 |
+
|
210 |
+
if weights and weights.strip():
|
211 |
+
weights_list = [str(w) for w in map(float, weights.split(','))]
|
212 |
+
ensemble_args += ["--weights", *weights_list]
|
213 |
+
|
214 |
+
result = subprocess.run(
|
215 |
+
["python", "ensemble.py"] + ensemble_args,
|
216 |
+
capture_output=True,
|
217 |
+
text=True
|
218 |
+
)
|
219 |
+
|
220 |
+
log = f"✅ Success!\n{result.stdout}" if not result.stderr else f"❌ Error!\n{result.stderr}"
|
221 |
+
return output_path, log
|
222 |
+
|
223 |
+
except Exception as e:
|
224 |
+
return None, f"⛔ Critical Error: {str(e)}"
|
225 |
+
|
226 |
+
def auto_ensemble_process(input_audio_file, selected_models, chunk_size, overlap, export_format, use_tta, extract_instrumental, ensemble_type, _state, *args, **kwargs):
|
227 |
+
"""Processes audio with multiple models and performs ensemble."""
|
228 |
+
try:
|
229 |
+
if not selected_models or len(selected_models) < 1:
|
230 |
+
return None, "❌ No models selected"
|
231 |
+
|
232 |
+
if input_audio_file is None:
|
233 |
+
existing_files = os.listdir(INPUT_DIR)
|
234 |
+
if not existing_files:
|
235 |
+
return None, "❌ No input audio provided"
|
236 |
+
audio_path = os.path.join(INPUT_DIR, existing_files[0])
|
237 |
+
else:
|
238 |
+
audio_path = input_audio_file.name
|
239 |
+
|
240 |
+
# AUTO_ENSEMBLE_TEMP'i de BASE_DIR üzerinden tanımla
|
241 |
+
auto_ensemble_temp = os.path.join(BASE_DIR, "auto_ensemble_temp")
|
242 |
+
os.makedirs(auto_ensemble_temp, exist_ok=True)
|
243 |
+
os.makedirs(AUTO_ENSEMBLE_OUTPUT, exist_ok=True)
|
244 |
+
clear_directory(auto_ensemble_temp)
|
245 |
+
|
246 |
+
all_outputs = []
|
247 |
+
for model in selected_models:
|
248 |
+
clean_model = extract_model_name(model)
|
249 |
+
model_output_dir = os.path.join(auto_ensemble_temp, clean_model)
|
250 |
+
os.makedirs(model_output_dir, exist_ok=True)
|
251 |
+
|
252 |
+
model_type, config_path, start_check_point = get_model_config(clean_model, chunk_size, overlap)
|
253 |
+
|
254 |
+
cmd = [
|
255 |
+
"python", INFERENCE_PATH,
|
256 |
+
"--model_type", model_type,
|
257 |
+
"--config_path", config_path,
|
258 |
+
"--start_check_point", start_check_point,
|
259 |
+
"--input_folder", INPUT_DIR,
|
260 |
+
"--store_dir", model_output_dir,
|
261 |
+
]
|
262 |
+
if use_tta:
|
263 |
+
cmd.append("--use_tta")
|
264 |
+
if extract_instrumental:
|
265 |
+
cmd.append("--extract_instrumental")
|
266 |
+
|
267 |
+
print(f"Running command: {' '.join(cmd)}")
|
268 |
+
try:
|
269 |
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
270 |
+
print(result.stdout)
|
271 |
+
if result.returncode != 0:
|
272 |
+
print(f"Error: {result.stderr}")
|
273 |
+
return None, f"Model {model} failed: {result.stderr}"
|
274 |
+
except Exception as e:
|
275 |
+
return None, f"Critical error with {model}: {str(e)}"
|
276 |
+
|
277 |
+
model_outputs = glob.glob(os.path.join(model_output_dir, "*.wav"))
|
278 |
+
if not model_outputs:
|
279 |
+
raise FileNotFoundError(f"{model} failed to produce output")
|
280 |
+
all_outputs.extend(model_outputs)
|
281 |
+
|
282 |
+
def wait_for_files(files, timeout=300):
|
283 |
+
start = time.time()
|
284 |
+
while time.time() - start < timeout:
|
285 |
+
missing = [f for f in files if not os.path.exists(f)]
|
286 |
+
if not missing:
|
287 |
+
return True
|
288 |
+
time.sleep(5)
|
289 |
+
raise TimeoutError(f"Missing files: {missing[:3]}...")
|
290 |
+
|
291 |
+
wait_for_files(all_outputs)
|
292 |
+
|
293 |
+
quoted_files = [f'"{f}"' for f in all_outputs]
|
294 |
+
timestamp = str(int(time.time()))
|
295 |
+
output_path = os.path.join(AUTO_ENSEMBLE_OUTPUT, f"ensemble_{timestamp}.wav")
|
296 |
+
|
297 |
+
ensemble_cmd = [
|
298 |
+
"python", "ensemble.py",
|
299 |
+
"--files", *quoted_files,
|
300 |
+
"--type", ensemble_type,
|
301 |
+
"--output", f'"{output_path}"'
|
302 |
+
]
|
303 |
+
|
304 |
+
result = subprocess.run(
|
305 |
+
" ".join(ensemble_cmd),
|
306 |
+
shell=True,
|
307 |
+
capture_output=True,
|
308 |
+
text=True,
|
309 |
+
check=True
|
310 |
+
)
|
311 |
+
|
312 |
+
if not os.path.exists(output_path):
|
313 |
+
raise RuntimeError("Ensemble dosyası oluşturulamadı")
|
314 |
+
|
315 |
+
return output_path, "✅ Success!"
|
316 |
+
except Exception as e:
|
317 |
+
return None, f"❌ Error: {str(e)}"
|
318 |
+
finally:
|
319 |
+
shutil.rmtree(auto_ensemble_temp, ignore_errors=True)
|
320 |
+
gc.collect()
|
requirements.txt
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pip
|
2 |
+
setuptools
|
3 |
+
wheel
|
4 |
+
numpy
|
5 |
+
pandas
|
6 |
+
scipy
|
7 |
+
torch
|
8 |
+
torchvision
|
9 |
+
torchmetrics
|
10 |
+
ml_collections
|
11 |
+
segmentation_models_pytorch
|
12 |
+
einops
|
13 |
+
matplotlib
|
14 |
+
librosa
|
15 |
+
soundfile
|
16 |
+
demucs
|
17 |
+
audiomentations
|
18 |
+
torch_audiomentations
|
19 |
+
httpx
|
20 |
+
gradio
|
21 |
+
google-api-python-client
|
22 |
+
validators
|
23 |
+
pytube
|
24 |
+
tqdm
|
25 |
+
psutil
|
26 |
+
omegaconf
|
27 |
+
beartype
|
28 |
+
asteroid
|
29 |
+
torchseg
|
30 |
+
yt_dlp
|
31 |
+
rotary_embedding_torch
|
32 |
+
noisereduce
|
33 |
+
loralib
|
34 |
+
hyper_connections==0.1.11
|
35 |
+
pyngrok
|