Spaces:
Sleeping
Sleeping
new model
#1
by BGdo - opened
- app.py +3 -59
- assets/models.json +15 -15
- requirements.txt +2 -3
app.py
CHANGED
|
@@ -118,9 +118,9 @@ roformer_models = {
|
|
| 118 |
'MelBand Roformer | Aspiration by Sucial' : 'aspiration_mel_band_roformer_sdr_18.9845.ckpt',
|
| 119 |
'MelBand Roformer | Aspiration Less Aggressive by Sucial' : 'aspiration_mel_band_roformer_less_aggr_sdr_18.1201.ckpt',
|
| 120 |
'MelBand Roformer | Bleed Suppressor V1 by unwa-97chris' : 'mel_band_roformer_bleed_suppressor_v1.ckpt',
|
| 121 |
-
'BS Roformer |
|
| 122 |
-
'BS Roformer |
|
| 123 |
-
'BS Roformer |
|
| 124 |
}
|
| 125 |
|
| 126 |
#=========================#
|
|
@@ -240,58 +240,6 @@ out_dir = "./outputs"
|
|
| 240 |
models_dir = "./models"
|
| 241 |
extensions = (".wav", ".flac", ".mp3", ".ogg", ".opus", ".m4a", ".aiff", ".ac3")
|
| 242 |
|
| 243 |
-
def download_model_files_manual(model_key, model_filename, output_dir="./models"):
|
| 244 |
-
"""
|
| 245 |
-
Manually download model files from models.json configuration.
|
| 246 |
-
This is needed for custom models not in audio-separator's built-in list.
|
| 247 |
-
The YAML config file will be renamed to match the model filename.
|
| 248 |
-
"""
|
| 249 |
-
import requests
|
| 250 |
-
|
| 251 |
-
os.makedirs(output_dir, exist_ok=True)
|
| 252 |
-
|
| 253 |
-
with open(models_file, 'r', encoding='utf-8') as file:
|
| 254 |
-
model_data = json.load(file)
|
| 255 |
-
|
| 256 |
-
if model_key not in model_data:
|
| 257 |
-
return False
|
| 258 |
-
|
| 259 |
-
urls = model_data[model_key]
|
| 260 |
-
all_downloaded = True
|
| 261 |
-
|
| 262 |
-
# Get the base name of the model file (without extension)
|
| 263 |
-
model_base_name = os.path.splitext(model_filename)[0]
|
| 264 |
-
|
| 265 |
-
for url in urls:
|
| 266 |
-
original_filename = os.path.basename(urllib.parse.urlparse(url).path)
|
| 267 |
-
|
| 268 |
-
# If this is a yaml/yml config file, rename it to match the model filename
|
| 269 |
-
if original_filename.endswith('.yaml') or original_filename.endswith('.yml'):
|
| 270 |
-
filename = f"{model_base_name}.yaml"
|
| 271 |
-
else:
|
| 272 |
-
filename = original_filename
|
| 273 |
-
|
| 274 |
-
full_path = os.path.join(output_dir, filename)
|
| 275 |
-
|
| 276 |
-
if os.path.exists(full_path):
|
| 277 |
-
print(f"{filename} already exists, skipping download.")
|
| 278 |
-
continue
|
| 279 |
-
|
| 280 |
-
print(f"Downloading {original_filename} as {filename} from {url}...")
|
| 281 |
-
try:
|
| 282 |
-
response = requests.get(url, stream=True, timeout=600)
|
| 283 |
-
response.raise_for_status()
|
| 284 |
-
|
| 285 |
-
with open(full_path, 'wb') as f:
|
| 286 |
-
for chunk in response.iter_content(chunk_size=8192):
|
| 287 |
-
f.write(chunk)
|
| 288 |
-
print(f"Successfully downloaded {filename}")
|
| 289 |
-
except Exception as e:
|
| 290 |
-
print(f"Error downloading {filename}: {e}")
|
| 291 |
-
all_downloaded = False
|
| 292 |
-
|
| 293 |
-
return all_downloaded
|
| 294 |
-
|
| 295 |
def load_config_presence():
|
| 296 |
with open(config_file, "r", encoding="utf8") as file:
|
| 297 |
config = json.load(file)
|
|
@@ -578,8 +526,6 @@ def roformer_separator(audio, model_key, out_format, segment_size, override_seg_
|
|
| 578 |
try:
|
| 579 |
if not os.path.exists(model_path):
|
| 580 |
gr.Info(f"This is the first time the {model_key} model is being used. The separation will take a little longer because the model needs to be downloaded.")
|
| 581 |
-
# Try to manually download custom models that aren't in audio-separator's built-in list
|
| 582 |
-
download_model_files_manual(model_key, roformer_model, models_dir)
|
| 583 |
|
| 584 |
separator = Separator(
|
| 585 |
log_level=logging.WARNING,
|
|
@@ -798,8 +744,6 @@ def roformer_batch(path_input, path_output, model_key, out_format, segment_size,
|
|
| 798 |
|
| 799 |
if not os.path.exists(model_path):
|
| 800 |
gr.Info(f"This is the first time the {model_key} model is being used. The separation will take a little longer because the model needs to be downloaded.")
|
| 801 |
-
# Try to manually download custom models that aren't in audio-separator's built-in list
|
| 802 |
-
download_model_files_manual(model_key, roformer_model, models_dir)
|
| 803 |
|
| 804 |
for audio_files in os.listdir(path_input):
|
| 805 |
if audio_files.endswith(extensions):
|
|
|
|
| 118 |
'MelBand Roformer | Aspiration by Sucial' : 'aspiration_mel_band_roformer_sdr_18.9845.ckpt',
|
| 119 |
'MelBand Roformer | Aspiration Less Aggressive by Sucial' : 'aspiration_mel_band_roformer_less_aggr_sdr_18.1201.ckpt',
|
| 120 |
'MelBand Roformer | Bleed Suppressor V1 by unwa-97chris' : 'mel_band_roformer_bleed_suppressor_v1.ckpt',
|
| 121 |
+
'BS Roformer | Revive by pcunwa': 'bs_roformer_revive.ckpt',
|
| 122 |
+
'BS Roformer | Revive 2 by pcunwa': 'bs_roformer_revive2.ckpt',
|
| 123 |
+
'BS Roformer | Revive 3e by pcunwa': 'bs_roformer_revive3e.ckpt'
|
| 124 |
}
|
| 125 |
|
| 126 |
#=========================#
|
|
|
|
| 240 |
models_dir = "./models"
|
| 241 |
extensions = (".wav", ".flac", ".mp3", ".ogg", ".opus", ".m4a", ".aiff", ".ac3")
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
def load_config_presence():
|
| 244 |
with open(config_file, "r", encoding="utf8") as file:
|
| 245 |
config = json.load(file)
|
|
|
|
| 526 |
try:
|
| 527 |
if not os.path.exists(model_path):
|
| 528 |
gr.Info(f"This is the first time the {model_key} model is being used. The separation will take a little longer because the model needs to be downloaded.")
|
|
|
|
|
|
|
| 529 |
|
| 530 |
separator = Separator(
|
| 531 |
log_level=logging.WARNING,
|
|
|
|
| 744 |
|
| 745 |
if not os.path.exists(model_path):
|
| 746 |
gr.Info(f"This is the first time the {model_key} model is being used. The separation will take a little longer because the model needs to be downloaded.")
|
|
|
|
|
|
|
| 747 |
|
| 748 |
for audio_files in os.listdir(path_input):
|
| 749 |
if audio_files.endswith(extensions):
|
assets/models.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
{
|
| 2 |
"BS-Roformer-Viperx-1297": [
|
| 3 |
-
|
| 4 |
-
|
| 5 |
],
|
| 6 |
"BS-Roformer-Viperx-1296": [
|
| 7 |
-
|
| 8 |
-
|
| 9 |
],
|
| 10 |
"BS-Roformer-Viperx-1053": [
|
| 11 |
-
|
| 12 |
-
|
| 13 |
],
|
| 14 |
"Mel-Roformer-Viperx-1143": [
|
| 15 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt",
|
|
@@ -291,17 +291,17 @@
|
|
| 291 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/aspiration_mel_band_roformer_less_aggr_sdr_18.1201.ckpt",
|
| 292 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/config_aspiration_mel_band_roformer.yaml"
|
| 293 |
],
|
| 294 |
-
"BS Roformer |
|
| 295 |
-
"https://
|
| 296 |
-
"https://
|
| 297 |
],
|
| 298 |
-
"BS Roformer |
|
| 299 |
-
"https://
|
| 300 |
-
"https://
|
| 301 |
],
|
| 302 |
-
"BS Roformer |
|
| 303 |
-
"https://
|
| 304 |
-
"https://
|
| 305 |
],
|
| 306 |
"MDX23C_D1581.ckpt": [
|
| 307 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/MDX23C_D1581.ckpt",
|
|
|
|
| 1 |
{
|
| 2 |
"BS-Roformer-Viperx-1297": [
|
| 3 |
+
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_bs_roformer_ep_317_sdr_12.9755.ckpt",
|
| 4 |
+
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_bs_roformer_ep_317_sdr_12.9755.yaml"
|
| 5 |
],
|
| 6 |
"BS-Roformer-Viperx-1296": [
|
| 7 |
+
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_bs_roformer_ep_368_sdr_12.9628.ckpt",
|
| 8 |
+
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_bs_roformer_ep_368_sdr_12.9628.yaml"
|
| 9 |
],
|
| 10 |
"BS-Roformer-Viperx-1053": [
|
| 11 |
+
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_bs_roformer_ep_937_sdr_10.5309.ckpt",
|
| 12 |
+
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_bs_roformer_ep_937_sdr_10.5309.yaml"
|
| 13 |
],
|
| 14 |
"Mel-Roformer-Viperx-1143": [
|
| 15 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt",
|
|
|
|
| 291 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/aspiration_mel_band_roformer_less_aggr_sdr_18.1201.ckpt",
|
| 292 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/config_aspiration_mel_band_roformer.yaml"
|
| 293 |
],
|
| 294 |
+
"BS Roformer | Revive by pcunwa": [
|
| 295 |
+
"https://huggingface.co/pcunwa/BS-Roformer-Revive/resolve/main/bs_roformer_revive.ckpt",
|
| 296 |
+
"https://huggingface.co/pcunwa/BS-Roformer-Revive/resolve/main/config.yaml"
|
| 297 |
],
|
| 298 |
+
"BS Roformer | Revive 2 by pcunwa": [
|
| 299 |
+
"https://huggingface.co/pcunwa/BS-Roformer-Revive/resolve/main/bs_roformer_revive2.ckpt",
|
| 300 |
+
"https://huggingface.co/pcunwa/BS-Roformer-Revive/resolve/main/config.yaml"
|
| 301 |
],
|
| 302 |
+
"BS Roformer | Revive 3e by pcunwa": [
|
| 303 |
+
"https://huggingface.co/pcunwa/BS-Roformer-Revive/resolve/main/bs_roformer_revive3e.ckpt",
|
| 304 |
+
"https://huggingface.co/pcunwa/BS-Roformer-Revive/resolve/main/config.yaml"
|
| 305 |
],
|
| 306 |
"MDX23C_D1581.ckpt": [
|
| 307 |
"https://github.com/nomadkaraoke/python-audio-separator/releases/download/model-configs/MDX23C_D1581.ckpt",
|
requirements.txt
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
audio-separator[gpu]
|
| 2 |
yt_dlp
|
| 3 |
-
pypresence
|
| 4 |
-
requests
|
|
|
|
| 1 |
+
audio-separator[gpu]==0.35.2
|
| 2 |
yt_dlp
|
| 3 |
+
pypresence
|
|
|