Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| import subprocess | |
| from huggingface_hub import HfApi, Repository | |
| 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() | |