UVR-API / app.py
TheStinger's picture
Update app.py
c4fe304 verified
raw
history blame
6.65 kB
import gradio as gr
import spaces
from audio_separator.separator import Separator
separator = Separator()
roformer_models = {
'BS-Roformer-Viperx-1297.ckpt': 'model_bs_roformer_ep_317_sdr_12.9755.ckpt',
'BS-Roformer-Viperx-1296.ckpt': 'model_bs_roformer_ep_368_sdr_12.9628.ckpt',
'BS-Roformer-Viperx-1053.ckpt': 'model_bs_roformer_ep_937_sdr_10.5309.ckpt',
'Mel-Roformer-Viperx-1143.ckpt': 'model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt'
}
mdx23c_models = [
'MDX23C_D1581.ckpt',
'MDX23C-8KFFT-InstVoc_HQ.ckpt',
'MDX23C-8KFFT-InstVoc_HQ_2.ckpt',
]
mdxnet_models = [
'UVR-MDX-NET-Inst_full_292.onnx',
'UVR-MDX-NET_Inst_187_beta.onnx',
'UVR-MDX-NET_Inst_82_beta.onnx',
'UVR-MDX-NET_Inst_90_beta.onnx',
'UVR-MDX-NET_Main_340.onnx',
'UVR-MDX-NET_Main_390.onnx',
'UVR-MDX-NET_Main_406.onnx',
'UVR-MDX-NET_Main_427.onnx',
'UVR-MDX-NET_Main_438.onnx',
'UVR-MDX-NET-Inst_HQ_1.onnx',
'UVR-MDX-NET-Inst_HQ_2.onnx',
'UVR-MDX-NET-Inst_HQ_3.onnx',
'UVR-MDX-NET-Inst_HQ_4.onnx',
'UVR_MDXNET_Main.onnx',
'UVR-MDX-NET-Inst_Main.onnx',
'UVR_MDXNET_1_9703.onnx',
'UVR_MDXNET_2_9682.onnx',
'UVR_MDXNET_3_9662.onnx',
'UVR-MDX-NET-Inst_1.onnx',
'UVR-MDX-NET-Inst_2.onnx',
'UVR-MDX-NET-Inst_3.onnx',
'UVR_MDXNET_KARA.onnx',
'UVR_MDXNET_KARA_2.onnx',
'UVR_MDXNET_9482.onnx',
'UVR-MDX-NET-Voc_FT.onnx',
'Kim_Vocal_1.onnx',
'Kim_Vocal_2.onnx',
'Kim_Inst.onnx',
'Reverb_HQ_By_FoxJoy.onnx',
'UVR-MDX-NET_Crowd_HQ_1.onnx',
'kuielab_a_vocals.onnx',
'kuielab_a_other.onnx',
'kuielab_a_bass.onnx',
'kuielab_a_drums.onnx',
'kuielab_b_vocals.onnx',
'kuielab_b_other.onnx',
'kuielab_b_bass.onnx',
'kuielab_b_drums.onnx',
]
vrarch_models = [
'1_HP-UVR.pth',
'2_HP-UVR.pth',
'3_HP-Vocal-UVR.pth',
'4_HP-Vocal-UVR.pth',
'5_HP-Karaoke-UVR.pth',
'6_HP-Karaoke-UVR.pth',
'7_HP2-UVR.pth',
'8_HP2-UVR.pth',
'9_HP2-UVR.pth',
'10_SP-UVR-2B-32000-1.pth',
'11_SP-UVR-2B-32000-2.pth',
'12_SP-UVR-3B-44100.pth',
'13_SP-UVR-4B-44100-1.pth',
'14_SP-UVR-4B-44100-2.pth',
'15_SP-UVR-MID-44100-1.pth',
'16_SP-UVR-MID-44100-2.pth',
'17_HP-Wind_Inst-UVR.pth',
'UVR-De-Echo-Aggressive.pth',
'UVR-De-Echo-Normal.pth',
'UVR-DeEcho-DeReverb.pth',
'UVR-DeNoise-Lite.pth',
'UVR-DeNoise.pth',
'UVR-BVE-4B_SN-44100-1.pth',
'MGM_HIGHEND_v4.pth',
'MGM_LOWEND_A_v4.pth',
'MGM_LOWEND_B_v4.pth',
'MGM_MAIN_v4.pth',
]
demucs_models = [
'htdemucs_ft.yaml',
'htdemucs.yaml',
'hdemucs_mmi.yaml',
]
@spaces.GPU(duration=300)
def roformer_separator(audio, checkpoint_name):
full_checkpoint_name = roformer_models[checkpoint_name]
separator.load_model(full_checkpoint_name)
output_files = separator.separate(audio)
stem1 = output_files[0]
stem2 = output_files[1]
return stem1, stem2
@spaces.GPU(duration=300)
def mdx_vr_separator(audio, checkpoint_name):
separator.load_model(checkpoint_name)
output_files = separator.separate(audio)
stem1 = output_files[0]
stem2 = output_files[1]
return stem1, stem2
@spaces.GPU(duration=300)
def demucs_separator(audio, checkpoint_name):
separator.load_model(checkpoint_name)
output_files = separator.separate(audio)
stem1 = output_files[0]
stem2 = output_files[1]
stem3 = output_files[2]
stem4 = output_files[3]
return stem1, stem2, stem3, stem4
with gr.Blocks(title="🎵 UVR5 UI 🎵") as demo:
gr.Markdown("<h1> 🎵 UVR5 UI 🎵 </h1>")
with gr.Tab("Vocal Separator (UVR)"):
gr.Markdown("Separate vocals and instruments from an audio file using UVR models.")
with gr.Tab("Mel/BS Roformer"):
roformer_audio_file = gr.Audio(label="Audio File", type="filepath")
with gr.Row():
roformer_model = gr.Dropdown(label="Model", choices=list(roformer_models.keys()))
roformer_button = gr.Button("Separate", variant="primary")
roformer_stem1 = gr.Audio(type="filepath", label="Stem 1")
roformer_stem2 = gr.Audio(type="filepath", label="Stem 2")
roformer_button.click(roformer_separator, [roformer_audio_file, roformer_model], [roformer_stem1, roformer_stem2])
with gr.Tab("MDX23C"):
mdx23c_audio_file = gr.Audio(label="Audio File", type="filepath")
with gr.Row():
mdx23c_model = gr.Dropdown(label="Model", choices=mdx23c_models)
mdx23c_button = gr.Button("Separate", variant="primary")
mdx23c_stem1 = gr.Audio(type="filepath", label="Stem 1")
mdx23c_stem2 = gr.Audio(type="filepath", label="Stem 2")
mdx23c_button.click(mdx_vr_separator, [mdx23c_audio_file, mdx23c_model], [mdx23c_stem1, mdx23c_stem2])
with gr.Tab("MDX-NET"):
mdxnet_audio_file = gr.Audio(label="Audio File", type="filepath")
with gr.Row():
mdxnet_model = gr.Dropdown(label="Model", choices=mdxnet_models)
mdxnet_button = gr.Button("Separate", variant="primary")
mdxnet_stem1 = gr.Audio(type="filepath", label="Stem 1")
mdxnet_stem2 = gr.Audio(type="filepath", label="Stem 2")
mdxnet_button.click(mdx_vr_separator, [mdxnet_audio_file, mdxnet_model], [mdxnet_stem1, mdxnet_stem2])
with gr.Tab("VR-ARCH"):
vr_audio_file = gr.Audio(label="Audio File", type="filepath")
with gr.Row():
vr_model = gr.Dropdown(label="Model", choices=vrarch_models)
vr_button = gr.Button("Separate", variant="primary")
vr_stem1 = gr.Audio(type="filepath", label="Stem 1")
vr_stem2 = gr.Audio(type="filepath", label="Stem 2")
vr_button.click(mdx_vr_separator, [vr_audio_file, vr_model], [vr_stem1, vr_stem2])
with gr.Tab("Demucs"):
demucs_audio_file = gr.Audio(label="Audio File", type="filepath")
with gr.Row():
demucs_model = gr.Dropdown(label="Model", choices=demucs_models)
demucs_button = gr.Button("Separate", variant="primary")
demucs_stem1 = gr.Audio(type="filepath", label="Stem 1")
demucs_stem2 = gr.Audio(type="filepath", label="Stem 2")
demucs_stem3 = gr.Audio(type="filepath", label="Stem 3")
demucs_stem4 = gr.Audio(type="filepath", label="Stem 4")
demucs_button.click(demucs_separator, [demucs_audio_file, demucs_model], [demucs_stem1, demucs_stem2, demucs_stem3, demucs_stem4])
demo.launch()