File size: 1,490 Bytes
43c0fb7
dc19714
 
43c0fb7
dedff96
43c0fb7
08328de
43c0fb7
08328de
8e97121
08328de
eb851d8
 
43c0fb7
 
 
dbde0cb
43c0fb7
 
 
 
 
 
 
 
 
 
08328de
 
 
 
43c0fb7
 
 
 
 
eb851d8
43c0fb7
08328de
43c0fb7
 
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
from typing import Optional
import gradio as gr

import quantize
from huggingface_hub import HfApi, login

def run(model_id: str, model_version: str, additional_args: str, token: Optional[str] = None) -> str:
    if model_id == "":
        return "Please enter model_id."
    login(token=token)
    api = HfApi(token=token)

    quantize.quantize(api=api, model_id=model_id, model_version=model_version, additional_args=additional_args)


DESCRIPTION = """
Simple utility tool to quantize diffusion models and convert them to CoreML.
"""

title="Quantize model and convert to CoreML"

with gr.Blocks(title=title) as demo:
    description = gr.Markdown(f"""# {title}""")
    description = gr.Markdown(DESCRIPTION)

    with gr.Row() as r:
        with gr.Column() as c:
            model_id = gr.Text(max_lines=1, label="ID of output repo")
            model_version = gr.Text(max_lines=1, label="Version of model to convert", value="stabilityai/sd-turbo")
            additional_args = gr.Text(max_lines=1, label="Additional Args (optional)")
            token = gr.Text(max_lines=1, label="Your HuggingFace write token")
            with gr.Row() as c:
                clean = gr.ClearButton()
                submit = gr.Button("Submit", variant="primary")

        with gr.Column() as d:
            output = gr.Markdown()

    submit.click(run, inputs=[model_id, model_version, additional_args, token], outputs=output, concurrency_limit=1)

demo.queue(max_size=10).launch(show_api=True)