Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update app.py
Browse files39 unmodified lines404142434445464712 unmodified lines60616263646518 unmodified lines84858687888916 unmodified lines10610710810911011112 unmodified lines12412512612712812923 unmodified lines1531541551561571581599 unmodified lines16917017117239 unmodified linesexcept Exception as e:return error_str(e), gr.update(choices=[]), Nonedef convert_and_push(radio_model_names, input_model, ckpt_name, token, path_in_repo):model_id = url_to_model_id(input_model) if radio_model_names == "Other" else radio_model_namestry:12 unmodified linesckpt_path,"--dump_path" ,model_id,])18 unmodified linesreturn f"""Successfully converted the checkpoint and opened a PR to add the weights to the model repo.You can view and merge the PR [here]({hf_utils.get_pr_url(HfApi(token=token), model_id, commit_message)})."""except Exception as e:return error_str(e)16 unmodified linesmax_lines=1,label="Enter your Hugging Face token",placeholder="READ permission is enough",)gr.Markdown("You can get a token [here](https://huggingface.co/settings/tokens)")with gr.Group(visible=False) as group_model:12 unmodified linesgr.Markdown("## 2. Convert to Diffusers🧨")radio_ckpts = gr.Radio(label="Choose the checkpoint to convert", visible=False)path_in_repo = gr.Textbox(label="Path where the weights will be saved", placeholder="Leave empty for root folder")gr.Markdown("Conversion may take a few minutes.")btn_convert = gr.Button("Convert & Push")23 unmodified linesbtn_convert.click(fn=convert_and_push,inputs=[radio_model_names, input_model, radio_ckpts, input_token, path_in_repo],outputs=error_output,scroll_to_output=True)9 unmodified lines""")demo.queue()demo.launch(share=utils.is_google_colab())39 unmodified lines404142434445464748495012 unmodified lines636465666768697018 unmodified lines899091929394959616 unmodified lines11311411511611711811912 unmodified lines13213313413513613713823 unmodified lines1621631641651661671689 unmodified lines17817918018139 unmodified linesexcept Exception as e:return error_str(e), gr.update(choices=[]), Nonedef convert_and_push(radio_model_names, input_model, ckpt_name, sd_version, token, path_in_repo):if sd_version == None:return error_str("You must select a stable diffusion version.", title="Invalid input")model_id = url_to_model_id(input_model) if radio_model_names == "Other" else radio_model_namestry:12 unmodified linesckpt_path,"--dump_path" ,model_id,"--sd_version",sd_version])18 unmodified linesreturn f"""Successfully converted the checkpoint and opened a PR to add the weights to the model repo.You can view and merge the PR [here]({hf_utils.get_pr_url(HfApi(token=token), model_id, commit_message)})."""return "Done"except Exception as e:return error_str(e)16 unmodified linesmax_lines=1,label="Enter your Hugging Face token",placeholder="READ permission is enough",type='password')gr.Markdown("You can get a token [here](https://huggingface.co/settings/tokens)")with gr.Group(visible=False) as group_model:12 unmodified linesgr.Markdown("## 2. Convert to Diffusers🧨")radio_ckpts = gr.Radio(label="Choose the checkpoint to convert", visible=False)path_in_repo = gr.Textbox(label="Path where the weights will be saved", placeholder="Leave empty for root folder")radio_sd_version = gr.Radio(label="Choose the model version", choices=["v1", "v2", "v2.1"])gr.Markdown("Conversion may take a few minutes.")btn_convert = gr.Button("Convert & Push")23 unmodified linesbtn_convert.click(fn=convert_and_push,inputs=[radio_model_names, input_model, radio_ckpts, radio_sd_version, input_token, path_in_repo],outputs=error_output,scroll_to_output=True)9 unmodified lines""")demo.queue()demo.launch(debug=True, share=utils.is_google_colab())
app.py+12-3