File size: 1,868 Bytes
431af92
4ad7983
d5d52b4
431af92
54b4787
 
d5d52b4
 
8f4de93
 
 
 
 
d5d52b4
 
8f4de93
 
 
 
 
 
 
 
 
 
 
 
 
d5d52b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c56eedf
 
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
import subprocess
from huggingface_hub import HfApi, Repository, hf_hub_download
import gradio as gr

subprocess.run(["git", "clone", "https://github.com/huggingface/diffusers.git", "diff"])

def convert(token: str, model_id: str) -> str:
    
#    if token == "" or model_id == "":
#        return """
#        ### Invalid input 🐞
#        Please fill a token and model name.
#        """
    try:
        api = HfApi(token=token)
#        info = api.model_info(repo_id=model_id)
#        
#        # loop info siblings (type is RepoFile) and find the ones which rfilename ends with .ckpt, then return them
#        ckpt_files = [sibling for sibling in info.siblings if sibling.rfilename.endswith(".ckpt")]
#        if len(ckpt_files) == 0:
#            return f"#### Error: No checkpoint file found in the model repo."
#        
#        # return file names:
#        return "\n".join([f"- {ckpt_file.rfilename}" for ckpt_file in ckpt_files])
        api = HfApi()
        cpkt_path = hf_hub_download(repo_id="nitrosocke/Arcane-Diffusion", filename="arcane-diffusion-5k.ckpt")
        return cpkt_path
                
    except Exception as e:
        return f"#### Error: {e}"

with gr.Blocks() as demo:

    with gr.Row():
        with gr.Column(scale=50):
            gr.Markdown("DESCRIPTION")

        with gr.Column(scale=50):
            input_token = gr.Textbox(
                max_lines=1,
                label="Hugging Face token",
            )
            input_model = gr.Textbox(
                max_lines=1,
                label="Model name",
                placeholder="textattack/distilbert-base-cased-CoLA",
            )

            btn = gr.Button("Convert to Diffusers🧨")
            output = gr.Markdown(label="Output")

    btn.click(
        fn=convert, inputs=[input_token, input_model], outputs=output
    )
    
demo.launch()