|
import gradio as gr |
|
from tabs.typing_extra import download_online_model, RVC_MODELS_DIR, get_current_models, update_models_list, delete_model |
|
|
|
def download_tab(status_message, rvc_model): |
|
"""Define the Download Models tab UI.""" |
|
with gr.TabItem("Download Models"): |
|
with gr.Row(): |
|
model_zip_link = gr.Textbox( |
|
label="Model Download Link", |
|
placeholder="Enter URL to a .zip file containing the model", |
|
lines=1 |
|
) |
|
model_name = gr.Textbox( |
|
label="Model Name", |
|
placeholder="Enter a unique name for the model", |
|
lines=1 |
|
) |
|
with gr.Row(equal_height=True): |
|
download_btn = gr.Button("Download Model", variant="primary", size="lg") |
|
dl_output_message = gr.Textbox(label="Status", lines=2, interactive=False) |
|
|
|
download_btn.click( |
|
fn=download_online_model, |
|
inputs=[model_zip_link, model_name], |
|
outputs=[dl_output_message, status_message] |
|
).then( |
|
fn=update_models_list, |
|
outputs=[rvc_model, status_message] |
|
) |
|
|
|
gr.Markdown("### Example Models") |
|
gr.Examples( |
|
examples=[ |
|
["https://huggingface.co/megaaziib/my-rvc-models-collection/resolve/main/kobo.zip", "Kobo"], |
|
["https://pixeldrain.com/u/3tJmABXA", "Gura"], |
|
["https://huggingface.co/brookieisthatyou/MY-RVC-V2-MODELS/resolve/main/UziDoorman.zip", "Uzi"] |
|
], |
|
inputs=[model_zip_link, model_name], |
|
label="Try these sample models" |
|
) |
|
|
|
def model_manage_tab(status_message, rvc_model): |
|
"""Define the Manage Models tab UI.""" |
|
with gr.TabItem("Manage Models"): |
|
model_to_delete = gr.Dropdown( |
|
label="Select Model to Delete", |
|
choices=get_current_models(RVC_MODELS_DIR), |
|
allow_custom_value=False |
|
) |
|
with gr.Row(equal_height=True): |
|
delete_btn = gr.Button("Delete Model", size="lg") |
|
delete_output = gr.Textbox(label="Status", lines=2, interactive=False) |
|
|
|
delete_btn.click( |
|
fn=delete_model, |
|
inputs=model_to_delete, |
|
outputs=[delete_output, status_message] |
|
).then( |
|
fn=update_models_list, |
|
outputs=[rvc_model, model_to_delete, status_message] |
|
) |
|
|