Spaces:
Build error
Build error
Commit ·
38cb277
1
Parent(s): 5638854
Load local model
Browse files14 unmodified lines151617181920216 unmodified lines28293031323334353637383940414217 unmodified lines6061626364656667686970717273747576777879808182838485868788899091929394954 unmodified lines10010110210310410510610710810911011111211311411514 unmodified lines# The model will be loaded in the futureMODEL_NAME = CHECKPOINTS_DIR / "audiosep_base_4M_steps.ckpt"MODEL = Nonedescription = """6 unmodified lines"""def get_model():model = build_audiosep(config_yaml="config/audiosep_base.yaml",checkpoint_path=MODEL_NAME,device=DEVICE,)return modeldef inference(audio_file_path: str, text: str):print(f"Separate audio from [{audio_file_path}] with textual query [{text}]")mixture, _ = librosa.load(audio_file_path, sr=32000, mono=True)17 unmodified linesreturn 32000, np.round(sep_segment * 32767).astype(np.int16)def download_models():CHECKPOINTS_DIR.mkdir(exist_ok=True)success_file = CHECKPOINTS_DIR / "_SUCCESS"models = (("https://drive.google.com/file/d/1wQuXThdATXrkmkPM2sRGaNapJ4mTqmlY/view?usp=sharing",MODEL_NAME,),("https://drive.google.com/file/d/11oj8_tPG6SXgw5fIEsZ5HiWZnJOrvdhw/view?usp=sharing",CHECKPOINTS_DIR / "music_speech_audioset_epoch_15_esc_89.98.pt",),)def download(models):for model_url, model_path in models:gdown.download(model_url, str(model_path), quiet=False, fuzzy=True)success_file.touch()global MODELMODEL = get_model()button.update(value="Separate", interactive=True)if not success_file.exists():thread = Thread(target=download, args=[models])thread.start()with gr.Blocks(title="AudioSep") as demo:gr.Markdown(description)with gr.Row():4 unmodified lineswith gr.Column():output_audio = gr.Audio(scale=10)button = gr.Button("Downloading the models...",variant="primary",scale=2,size="lg",interactive=False,)button.click(fn=inference, inputs=[input_audio, text], outputs=[output_audio])download_models()demo.queue().launch(share=True)14 unmodified lines15161718192021222324256 unmodified lines32333435363717 unmodified lines5556575859604 unmodified lines656667686970717273747576777814 unmodified lines# The model will be loaded in the futureMODEL_NAME = CHECKPOINTS_DIR / "audiosep_base_4M_steps.ckpt"MODEL = build_audiosep(config_yaml="config/audiosep_base.yaml",checkpoint_path=MODEL_NAME,device=DEVICE,)description = """6 unmodified lines"""def inference(audio_file_path: str, text: str):print(f"Separate audio from [{audio_file_path}] with textual query [{text}]")mixture, _ = librosa.load(audio_file_path, sr=32000, mono=True)17 unmodified linesreturn 32000, np.round(sep_segment * 32767).astype(np.int16)with gr.Blocks(title="AudioSep") as demo:gr.Markdown(description)with gr.Row():4 unmodified lineswith gr.Column():output_audio = gr.Audio(scale=10)button = gr.Button("Separate",variant="primary",scale=2,size="lg",interactive=True,)button.click(fn=inference, inputs=[input_audio, text], outputs=[output_audio])demo.queue().launch(share=True)
app.py+7-44