File size: 2,452 Bytes
1c7d911
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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]
        )