File size: 1,916 Bytes
55148b0
e36495b
 
 
55148b0
 
 
e36495b
6558963
e36495b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55148b0
 
e36495b
 
 
 
55148b0
 
 
 
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
import gradio as gr
import os
from convert_repo_to_safetensors_gr import convert_repo_to_safetensors_multi
os.environ['HF_OUTPUT_REPO'] = 'John6666/safetensors_converting_test'

css = """"""

with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css, delete_cache=(60, 3600)) as demo:
    gr.Markdown(
            f"""

    - [A CLI version of this tool is available here](https://huggingface.co/spaces/John6666/convert_repo_to_safetensors/tree/main/local).

    """)
    with gr.Column(): 
        repo_id = gr.Textbox(label="Repo ID", placeholder="author/model", value="", lines=1)
        is_upload = gr.Checkbox(label="Upload safetensors to HF Repo", info="Fast download, but files will be public.", value=False)
        with gr.Accordion("Advanced", open=False):
            dtype = gr.Radio(label="Output data type", choices=["fp16", "fp32", "bf16", "default"], value="fp16")
            hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
            with gr.Row():
                newrepo_id = gr.Textbox(label="Upload repo ID", placeholder="author/model", value="", max_lines=1)
                newrepo_type = gr.Radio(label="Upload repo type", choices=["model", "dataset"], value="model")
                is_private = gr.Checkbox(label="Create / Use private repo", value=True)
        uploaded_urls = gr.CheckboxGroup(visible=False, choices=[], value=None) # hidden
        run_button = gr.Button(value="Convert")
        st_file = gr.Files(label="Output", interactive=False)
        st_md = gr.Markdown()

    gr.on(
        triggers=[repo_id.submit, run_button.click],
        fn=convert_repo_to_safetensors_multi,
        inputs=[repo_id, hf_token, st_file, uploaded_urls, dtype, is_upload, newrepo_id, newrepo_type, is_private],
        outputs=[st_file, uploaded_urls, st_md],
    )

demo.queue()
demo.launch()