Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -40,8 +40,11 @@ def get_ckpt_names(token, radio_model_names, input_model):
|
|
40 |
except Exception as e:
|
41 |
return error_str(e), gr.update(choices=[]), None
|
42 |
|
43 |
-
def convert_and_push(radio_model_names, input_model, ckpt_name, token, path_in_repo):
|
44 |
|
|
|
|
|
|
|
45 |
model_id = url_to_model_id(input_model) if radio_model_names == "Other" else radio_model_names
|
46 |
|
47 |
try:
|
@@ -60,6 +63,8 @@ def convert_and_push(radio_model_names, input_model, ckpt_name, token, path_in_r
|
|
60 |
ckpt_path,
|
61 |
"--dump_path" ,
|
62 |
model_id,
|
|
|
|
|
63 |
]
|
64 |
)
|
65 |
|
@@ -84,6 +89,8 @@ def convert_and_push(radio_model_names, input_model, ckpt_name, token, path_in_r
|
|
84 |
|
85 |
return f"""Successfully converted the checkpoint and opened a PR to add the weights to the model repo.
|
86 |
You can view and merge the PR [here]({hf_utils.get_pr_url(HfApi(token=token), model_id, commit_message)})."""
|
|
|
|
|
87 |
|
88 |
except Exception as e:
|
89 |
return error_str(e)
|
@@ -106,6 +113,7 @@ with gr.Blocks() as demo:
|
|
106 |
max_lines=1,
|
107 |
label="Enter your Hugging Face token",
|
108 |
placeholder="READ permission is enough",
|
|
|
109 |
)
|
110 |
gr.Markdown("You can get a token [here](https://huggingface.co/settings/tokens)")
|
111 |
with gr.Group(visible=False) as group_model:
|
@@ -124,6 +132,7 @@ with gr.Blocks() as demo:
|
|
124 |
gr.Markdown("## 2. Convert to Diffusers🧨")
|
125 |
radio_ckpts = gr.Radio(label="Choose the checkpoint to convert", visible=False)
|
126 |
path_in_repo = gr.Textbox(label="Path where the weights will be saved", placeholder="Leave empty for root folder")
|
|
|
127 |
gr.Markdown("Conversion may take a few minutes.")
|
128 |
btn_convert = gr.Button("Convert & Push")
|
129 |
|
@@ -153,7 +162,7 @@ with gr.Blocks() as demo:
|
|
153 |
|
154 |
btn_convert.click(
|
155 |
fn=convert_and_push,
|
156 |
-
inputs=[radio_model_names, input_model, radio_ckpts, input_token, path_in_repo],
|
157 |
outputs=error_output,
|
158 |
scroll_to_output=True
|
159 |
)
|
@@ -169,4 +178,4 @@ with gr.Blocks() as demo:
|
|
169 |
""")
|
170 |
|
171 |
demo.queue()
|
172 |
-
demo.launch(share=utils.is_google_colab())
|
|
|
40 |
except Exception as e:
|
41 |
return error_str(e), gr.update(choices=[]), None
|
42 |
|
43 |
+
def convert_and_push(radio_model_names, input_model, ckpt_name, sd_version, token, path_in_repo):
|
44 |
|
45 |
+
if sd_version == None:
|
46 |
+
return error_str("You must select a stable diffusion version.", title="Invalid input")
|
47 |
+
|
48 |
model_id = url_to_model_id(input_model) if radio_model_names == "Other" else radio_model_names
|
49 |
|
50 |
try:
|
|
|
63 |
ckpt_path,
|
64 |
"--dump_path" ,
|
65 |
model_id,
|
66 |
+
"--sd_version",
|
67 |
+
sd_version
|
68 |
]
|
69 |
)
|
70 |
|
|
|
89 |
|
90 |
return f"""Successfully converted the checkpoint and opened a PR to add the weights to the model repo.
|
91 |
You can view and merge the PR [here]({hf_utils.get_pr_url(HfApi(token=token), model_id, commit_message)})."""
|
92 |
+
|
93 |
+
return "Done"
|
94 |
|
95 |
except Exception as e:
|
96 |
return error_str(e)
|
|
|
113 |
max_lines=1,
|
114 |
label="Enter your Hugging Face token",
|
115 |
placeholder="READ permission is enough",
|
116 |
+
type='password'
|
117 |
)
|
118 |
gr.Markdown("You can get a token [here](https://huggingface.co/settings/tokens)")
|
119 |
with gr.Group(visible=False) as group_model:
|
|
|
132 |
gr.Markdown("## 2. Convert to Diffusers🧨")
|
133 |
radio_ckpts = gr.Radio(label="Choose the checkpoint to convert", visible=False)
|
134 |
path_in_repo = gr.Textbox(label="Path where the weights will be saved", placeholder="Leave empty for root folder")
|
135 |
+
radio_sd_version = gr.Radio(label="Choose the model version", choices=["v1", "v2", "v2.1"])
|
136 |
gr.Markdown("Conversion may take a few minutes.")
|
137 |
btn_convert = gr.Button("Convert & Push")
|
138 |
|
|
|
162 |
|
163 |
btn_convert.click(
|
164 |
fn=convert_and_push,
|
165 |
+
inputs=[radio_model_names, input_model, radio_ckpts, radio_sd_version, input_token, path_in_repo],
|
166 |
outputs=error_output,
|
167 |
scroll_to_output=True
|
168 |
)
|
|
|
178 |
""")
|
179 |
|
180 |
demo.queue()
|
181 |
+
demo.launch(debug=True, share=utils.is_google_colab())
|