theNeofr commited on
Commit
c5200bd
1 Parent(s): 16b411b

Better WebUI

Browse files
Files changed (1) hide show
  1. app.py +284 -249
app.py CHANGED
@@ -1,249 +1,284 @@
1
- import gradio as gr
2
- from convert_url_to_diffusers_multi_gr import convert_url_to_diffusers_repo, get_dtypes, FLUX_BASE_REPOS, SD35_BASE_REPOS
3
- from presets import (DEFAULT_DTYPE, schedulers, clips, t5s, sdxl_vaes, sdxl_loras, sdxl_preset_dict, sdxl_set_presets,
4
- sd15_vaes, sd15_loras, sd15_preset_dict, sd15_set_presets, flux_vaes, flux_loras, flux_preset_dict, flux_set_presets,
5
- sd35_vaes, sd35_loras, sd35_preset_dict, sd35_set_presets)
6
- import os
7
-
8
-
9
- HF_USER = os.getenv("HF_USER", "")
10
- HF_REPO = os.getenv("HF_REPO", "")
11
- HF_URL = os.getenv("HF_URL", "")
12
- HF_OW = os.getenv("HF_OW", False)
13
- HF_PR = os.getenv("HF_PR", False)
14
-
15
- css = """
16
- .title { font-size: 3em; align-items: center; text-align: center; }
17
- .info { align-items: center; text-align: center; }
18
- .block.result { margin: 1em 0; padding: 1em; box-shadow: 0 0 3px 3px #664422, 0 0 3px 2px #664422 inset; border-radius: 6px; background: #665544; }
19
- """
20
-
21
- with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css, delete_cache=(60, 3600)) as demo:
22
- gr.Markdown("# Download SDXL / SD 1.5 / SD 3.5 / FLUX.1 safetensors and convert to HF🤗 Diffusers format and create your repo", elem_classes="title")
23
- gr.Markdown(f"""
24
- ### ⚠️IMPORTANT NOTICE⚠️<br>
25
- It's dangerous to expose your access token or key to others.
26
- If you do use it, I recommend that you duplicate this space on your own HF account in advance.
27
- Keys and tokens could be set to **Secrets** (`HF_TOKEN`, `CIVITAI_API_KEY`) if it's placed in your own space.
28
- It saves you the trouble of typing them in.<br>
29
- It barely works in the CPU space, but larger files can be converted if duplicated on the more powerful **Zero GPU** space.
30
- In particular, conversion of FLUX.1 or SD 3.5 is almost impossible in CPU space.
31
- ### The steps are the following:
32
- 1. Paste a write-access token from [hf.co/settings/tokens](https://huggingface.co/settings/tokens).
33
- 1. Input a model download url of the Hugging Face or Civitai or other sites.
34
- 1. If you want to download a model from Civitai, paste a Civitai API Key.
35
- 1. Input your HF user ID. e.g. 'yourid'.
36
- 1. Input your new repo name. If empty, auto-complete. e.g. 'newrepo'.
37
- 1. Set the parameters. If not sure, just use the defaults.
38
- 1. Click "Submit".
39
- 1. Patiently wait until the output changes. It takes approximately 2 to 3 minutes (on SDXL models downloading from HF).
40
- """)
41
- with gr.Column():
42
- dl_url = gr.Textbox(label="URL to download", placeholder="https://huggingface.co/bluepen5805/blue_pencil-XL/blob/main/blue_pencil-XL-v7.0.0.safetensors",
43
- value=HF_URL, max_lines=1)
44
- with gr.Group():
45
- with gr.Row():
46
- hf_user = gr.Textbox(label="Your HF user ID", placeholder="username", value=HF_USER, max_lines=1)
47
- hf_repo = gr.Textbox(label="New repo name", placeholder="reponame", info="If empty, auto-complete", value=HF_REPO, max_lines=1)
48
- with gr.Row(equal_height=True):
49
- with gr.Column():
50
- hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
51
- gr.Markdown("Your token is available at [hf.co/settings/tokens](https://huggingface.co/settings/tokens).", elem_classes="info")
52
- with gr.Column():
53
- civitai_key = gr.Textbox(label="Your Civitai API Key (Optional)", info="If you download model from Civitai...", placeholder="", value="", max_lines=1)
54
- gr.Markdown("Your Civitai API key is available at [https://civitai.com/user/account](https://civitai.com/user/account).", elem_classes="info")
55
- with gr.Row():
56
- is_upload_sf = gr.Checkbox(label="Upload single safetensors file into new repo", value=False)
57
- is_private = gr.Checkbox(label="Create private repo", value=True)
58
- is_overwrite = gr.Checkbox(label="Overwrite repo", value=HF_OW)
59
- is_pr = gr.Checkbox(label="Create PR", value=HF_PR)
60
- with gr.Tab("SDXL"):
61
- with gr.Group():
62
- sdxl_presets = gr.Radio(label="Presets", choices=list(sdxl_preset_dict.keys()), value=list(sdxl_preset_dict.keys())[0])
63
- sdxl_mtype = gr.Textbox(value="SDXL", visible=False)
64
- with gr.Row():
65
- sdxl_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value=DEFAULT_DTYPE)
66
- with gr.Accordion("Advanced settings", open=False):
67
- with gr.Row():
68
- sdxl_vae = gr.Dropdown(label="VAE", choices=sdxl_vaes, value="", allow_custom_value=True)
69
- sdxl_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
70
- sdxl_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler a")
71
- with gr.Row():
72
- with gr.Column():
73
- sdxl_lora1 = gr.Dropdown(label="LoRA1", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
74
- sdxl_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
75
- with gr.Column():
76
- sdxl_lora2 = gr.Dropdown(label="LoRA2", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
77
- sdxl_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
78
- with gr.Column():
79
- sdxl_lora3 = gr.Dropdown(label="LoRA3", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
80
- sdxl_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
81
- with gr.Column():
82
- sdxl_lora4 = gr.Dropdown(label="LoRA4", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
83
- sdxl_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
84
- with gr.Column():
85
- sdxl_lora5 = gr.Dropdown(label="LoRA5", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
86
- sdxl_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
87
- sdxl_run_button = gr.Button(value="Submit", variant="primary")
88
- with gr.Tab("SD 1.5"):
89
- with gr.Group():
90
- sd15_presets = gr.Radio(label="Presets", choices=list(sd15_preset_dict.keys()), value=list(sd15_preset_dict.keys())[0])
91
- sd15_mtype = gr.Textbox(value="SD 1.5", visible=False)
92
- with gr.Row():
93
- sd15_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value=DEFAULT_DTYPE)
94
- sd15_ema = gr.Checkbox(label="Extract EMA", value=True, visible=True)
95
- sd15_isize = gr.Radio(label="Image size", choices=["768", "512"], value="768")
96
- sd15_sc = gr.Checkbox(label="Safety checker", value=False)
97
- with gr.Accordion("Advanced settings", open=False):
98
- with gr.Row():
99
- sd15_vae = gr.Dropdown(label="VAE", choices=sd15_vaes, value="", allow_custom_value=True)
100
- sd15_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
101
- sd15_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler")
102
- with gr.Row():
103
- with gr.Column():
104
- sd15_lora1 = gr.Dropdown(label="LoRA1", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
105
- sd15_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
106
- with gr.Column():
107
- sd15_lora2 = gr.Dropdown(label="LoRA2", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
108
- sd15_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
109
- with gr.Column():
110
- sd15_lora3 = gr.Dropdown(label="LoRA3", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
111
- sd15_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
112
- with gr.Column():
113
- sd15_lora4 = gr.Dropdown(label="LoRA4", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
114
- sd15_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
115
- with gr.Column():
116
- sd15_lora5 = gr.Dropdown(label="LoRA5", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
117
- sd15_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
118
- sd15_run_button = gr.Button(value="Submit", variant="primary")
119
- with gr.Tab("FLUX.1"):
120
- with gr.Group():
121
- flux_presets = gr.Radio(label="Presets", choices=list(flux_preset_dict.keys()), value=list(flux_preset_dict.keys())[0])
122
- flux_mtype = gr.Textbox(value="FLUX", visible=False)
123
- with gr.Row():
124
- flux_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value="bf16")
125
- flux_base_repo = gr.Dropdown(label="Base repo ID", choices=FLUX_BASE_REPOS, value=FLUX_BASE_REPOS[0], allow_custom_value=True, visible=True)
126
- with gr.Accordion("Advanced settings", open=False):
127
- with gr.Row():
128
- flux_vae = gr.Dropdown(label="VAE", choices=flux_vaes, value="", allow_custom_value=True)
129
- flux_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
130
- flux_t5 = gr.Dropdown(label="T5", choices=t5s, value="", allow_custom_value=True)
131
- flux_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=[""], value="", visible=False)
132
- with gr.Row():
133
- with gr.Column():
134
- flux_lora1 = gr.Dropdown(label="LoRA1", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
135
- flux_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
136
- with gr.Column():
137
- flux_lora2 = gr.Dropdown(label="LoRA2", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
138
- flux_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
139
- with gr.Column():
140
- flux_lora3 = gr.Dropdown(label="LoRA3", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
141
- flux_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
142
- with gr.Column():
143
- flux_lora4 = gr.Dropdown(label="LoRA4", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
144
- flux_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
145
- with gr.Column():
146
- flux_lora5 = gr.Dropdown(label="LoRA5", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
147
- flux_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
148
- flux_run_button = gr.Button(value="Submit", variant="primary")
149
- with gr.Tab("SD 3.5"):
150
- with gr.Group():
151
- sd35_presets = gr.Radio(label="Presets", choices=list(sd35_preset_dict.keys()), value=list(sd35_preset_dict.keys())[0])
152
- sd35_mtype = gr.Textbox(value="SD 3.5", visible=False)
153
- with gr.Row():
154
- sd35_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value="bf16")
155
- sd35_base_repo = gr.Dropdown(label="Base repo ID", choices=SD35_BASE_REPOS, value=SD35_BASE_REPOS[0], allow_custom_value=True, visible=True)
156
- with gr.Accordion("Advanced settings", open=False):
157
- with gr.Row():
158
- sd35_vae = gr.Dropdown(label="VAE", choices=sd35_vaes, value="", allow_custom_value=True)
159
- sd35_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
160
- sd35_t5 = gr.Dropdown(label="T5", choices=t5s, value="", allow_custom_value=True)
161
- sd35_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=[""], value="", visible=False)
162
- with gr.Row():
163
- with gr.Column():
164
- sd35_lora1 = gr.Dropdown(label="LoRA1", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
165
- sd35_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
166
- with gr.Column():
167
- sd35_lora2 = gr.Dropdown(label="LoRA2", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
168
- sd35_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
169
- with gr.Column():
170
- sd35_lora3 = gr.Dropdown(label="LoRA3", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
171
- sd35_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
172
- with gr.Column():
173
- sd35_lora4 = gr.Dropdown(label="LoRA4", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
174
- sd35_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
175
- with gr.Column():
176
- sd35_lora5 = gr.Dropdown(label="LoRA5", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
177
- sd35_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
178
- sd35_run_button = gr.Button(value="Submit", variant="primary")
179
- adv_args = gr.Textbox(label="Advanced arguments", value="", visible=False)
180
- with gr.Group():
181
- repo_urls = gr.CheckboxGroup(visible=False, choices=[], value=[])
182
- output_md = gr.Markdown(label="Output", value="<br><br>", elem_classes="result")
183
- clear_button = gr.Button(value="Clear Output", variant="secondary")
184
- gr.DuplicateButton(value="Duplicate Space")
185
-
186
- gr.on(
187
- triggers=[sdxl_run_button.click],
188
- fn=convert_url_to_diffusers_repo,
189
- inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
190
- sdxl_dtype, sdxl_vae, sdxl_clip, flux_t5, sdxl_scheduler, sd15_ema, sd15_isize, sd15_sc, flux_base_repo, sdxl_mtype,
191
- sdxl_lora1, sdxl_lora1s, sdxl_lora2, sdxl_lora2s, sdxl_lora3, sdxl_lora3s, sdxl_lora4, sdxl_lora4s, sdxl_lora5, sdxl_lora5s, adv_args],
192
- outputs=[repo_urls, output_md],
193
- )
194
- sdxl_presets.change(
195
- fn=sdxl_set_presets,
196
- inputs=[sdxl_presets],
197
- outputs=[sdxl_dtype, sdxl_vae, sdxl_scheduler, sdxl_lora1, sdxl_lora1s, sdxl_lora2, sdxl_lora2s, sdxl_lora3, sdxl_lora3s,
198
- sdxl_lora4, sdxl_lora4s, sdxl_lora5, sdxl_lora5s],
199
- queue=False,
200
- )
201
- gr.on(
202
- triggers=[sd15_run_button.click],
203
- fn=convert_url_to_diffusers_repo,
204
- inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
205
- sd15_dtype, sd15_vae, sd15_clip, flux_t5, sd15_scheduler, sd15_ema, sd15_isize, sd15_sc, flux_base_repo, sd15_mtype,
206
- sd15_lora1, sd15_lora1s, sd15_lora2, sd15_lora2s, sd15_lora3, sd15_lora3s, sd15_lora4, sd15_lora4s, sd15_lora5, sd15_lora5s, adv_args],
207
- outputs=[repo_urls, output_md],
208
- )
209
- sd15_presets.change(
210
- fn=sd15_set_presets,
211
- inputs=[sd15_presets],
212
- outputs=[sd15_dtype, sd15_vae, sd15_scheduler, sd15_lora1, sd15_lora1s, sd15_lora2, sd15_lora2s, sd15_lora3, sd15_lora3s,
213
- sd15_lora4, sd15_lora4s, sd15_lora5, sd15_lora5s, sd15_ema],
214
- queue=False,
215
- )
216
- gr.on(
217
- triggers=[flux_run_button.click],
218
- fn=convert_url_to_diffusers_repo,
219
- inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
220
- flux_dtype, flux_vae, flux_clip, flux_t5, flux_scheduler, sd15_ema, sd15_isize, sd15_sc, flux_base_repo, flux_mtype,
221
- flux_lora1, flux_lora1s, flux_lora2, flux_lora2s, flux_lora3, flux_lora3s, flux_lora4, flux_lora4s, flux_lora5, flux_lora5s, adv_args],
222
- outputs=[repo_urls, output_md],
223
- )
224
- flux_presets.change(
225
- fn=flux_set_presets,
226
- inputs=[flux_presets],
227
- outputs=[flux_dtype, flux_vae, flux_scheduler, flux_lora1, flux_lora1s, flux_lora2, flux_lora2s, flux_lora3, flux_lora3s,
228
- flux_lora4, flux_lora4s, flux_lora5, flux_lora5s, flux_base_repo],
229
- queue=False,
230
- )
231
- gr.on(
232
- triggers=[sd35_run_button.click],
233
- fn=convert_url_to_diffusers_repo,
234
- inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
235
- sd35_dtype, sd35_vae, sd35_clip, sd35_t5, sd35_scheduler, sd15_ema, sd15_isize, sd15_sc, sd35_base_repo, sd35_mtype,
236
- sd35_lora1, sd35_lora1s, sd35_lora2, sd35_lora2s, sd35_lora3, sd35_lora3s, sd35_lora4, sd35_lora4s, sd35_lora5, sd35_lora5s, adv_args],
237
- outputs=[repo_urls, output_md],
238
- )
239
- sd35_presets.change(
240
- fn=sd35_set_presets,
241
- inputs=[sd35_presets],
242
- outputs=[sd35_dtype, sd35_vae, sd35_scheduler, sd35_lora1, sd35_lora1s, sd35_lora2, sd35_lora2s, sd35_lora3, sd35_lora3s,
243
- sd35_lora4, sd35_lora4s, sd35_lora5, sd35_lora5s, sd35_base_repo],
244
- queue=False,
245
- )
246
- clear_button.click(lambda: ([], "<br><br>"), None, [repo_urls, output_md], queue=False, show_api=False)
247
-
248
- demo.queue()
249
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from convert_url_to_diffusers_multi_gr import convert_url_to_diffusers_repo, get_dtypes, FLUX_BASE_REPOS, SD35_BASE_REPOS
3
+ from presets import (DEFAULT_DTYPE, schedulers, clips, t5s, sdxl_vaes, sdxl_loras, sdxl_preset_dict, sdxl_set_presets,
4
+ sd15_vaes, sd15_loras, sd15_preset_dict, sd15_set_presets, flux_vaes, flux_loras, flux_preset_dict, flux_set_presets,
5
+ sd35_vaes, sd35_loras, sd35_preset_dict, sd35_set_presets)
6
+ import os
7
+
8
+
9
+ HF_USER = os.getenv("HF_USER", "")
10
+ HF_REPO = os.getenv("HF_REPO", "")
11
+ HF_URL = os.getenv("HF_URL", "")
12
+ HF_OW = os.getenv("HF_OW", False)
13
+ HF_PR = os.getenv("HF_PR", False)
14
+
15
+ css = """
16
+ .title { font-size: 3em; align-items: center; text-align: center; }
17
+ .info { align-items: center; text-align: center; }
18
+ .block.result { margin: 1em 0; padding: 1em; box-shadow: 0 0 3px 3px #664422, 0 0 3px 2px #664422 inset; border-radius: 6px; background: #665544; }
19
+ """
20
+
21
+ with gr.Blocks(theme="theNeofr/Syne", fill_width=True, css=css, delete_cache=(60, 3600)) as demo:
22
+ gr.Markdown("# Download SDXL / SD 1.5 / SD 3.5 / FLUX.1 safetensors and convert to HF🤗 Diffusers format and create your repo", elem_classes="title")
23
+ gr.Markdown(f"""
24
+ ### ⚠️IMPORTANT NOTICE⚠️<br>
25
+ It's dangerous to expose your access token or key to others.
26
+ If you do use it, I recommend that you duplicate this space on your own HF account in advance.
27
+ Keys and tokens could be set to **Secrets** (`HF_TOKEN`, `CIVITAI_API_KEY`) if it's placed in your own space.
28
+ It saves you the trouble of typing them in.<br>
29
+ It barely works in the CPU space, but larger files can be converted if duplicated on the more powerful **Zero GPU** space.
30
+ In particular, conversion of FLUX.1 or SD 3.5 is almost impossible in CPU space.
31
+ ### The steps are the following:
32
+ 1. Paste a write-access token from [hf.co/settings/tokens](https://huggingface.co/settings/tokens).
33
+ 1. Input a model download url of the Hugging Face or Civitai or other sites.
34
+ 1. If you want to download a model from Civitai, paste a Civitai API Key.
35
+ 1. Input your HF user ID. e.g. 'yourid'.
36
+ 1. Input your new repo name. If empty, auto-complete. e.g. 'newrepo'.
37
+ 1. Set the parameters. If not sure, just use the defaults.
38
+ 1. Click "Submit".
39
+ 1. Patiently wait until the output changes. It takes approximately 2 to 3 minutes (on SDXL models downloading from HF).
40
+ """)
41
+ with gr.Column():
42
+ dl_url = gr.Textbox(label="URL to download", placeholder="https://huggingface.co/bluepen5805/blue_pencil-XL/blob/main/blue_pencil-XL-v7.0.0.safetensors",
43
+ value=HF_URL, max_lines=1)
44
+ with gr.Group():
45
+ with gr.Row():
46
+ hf_user = gr.Textbox(label="Your HF user ID", placeholder="username", value=HF_USER, max_lines=1)
47
+ hf_repo = gr.Textbox(label="New repo name", placeholder="reponame", info="If empty, auto-complete", value=HF_REPO, max_lines=1)
48
+ with gr.Row(equal_height=True):
49
+ with gr.Column():
50
+ hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
51
+ gr.Markdown("Your token is available at [hf.co/settings/tokens](https://huggingface.co/settings/tokens).", elem_classes="info")
52
+ with gr.Column():
53
+ civitai_key = gr.Textbox(label="Your Civitai API Key (Optional)", info="If you download model from Civitai...", placeholder="", value="", max_lines=1)
54
+ gr.Markdown("Your Civitai API key is available at [https://civitai.com/user/account](https://civitai.com/user/account).", elem_classes="info")
55
+ with gr.Row():
56
+ is_upload_sf = gr.Checkbox(label="Upload single safetensors file into new repo", value=False)
57
+ is_private = gr.Checkbox(label="Create private repo", value=True)
58
+ with gr.Row():
59
+ is_overwrite = gr.Checkbox(label="Overwrite repo", value=HF_OW)
60
+ is_pr = gr.Checkbox(label="Create PR", value=HF_PR)
61
+ with gr.Tab("SDXL"):
62
+ with gr.Group():
63
+ sdxl_presets = gr.Radio(label="Presets", choices=list(sdxl_preset_dict.keys()), value=list(sdxl_preset_dict.keys())[0])
64
+ sdxl_mtype = gr.Textbox(value="SDXL", visible=False)
65
+ with gr.Row():
66
+ sdxl_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value=DEFAULT_DTYPE)
67
+ with gr.Accordion("Advanced settings", open=False):
68
+ with gr.Row():
69
+ sdxl_vae = gr.Dropdown(label="VAE", choices=sdxl_vaes, value="", allow_custom_value=True)
70
+ sdxl_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
71
+ sdxl_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler a")
72
+ with gr.Row():
73
+ with gr.Column():
74
+ with gr.Row():
75
+ sdxl_lora1 = gr.Dropdown(label="LoRA1", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
76
+ sdxl_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
77
+ with gr.Column():
78
+ with gr.Row():
79
+ sdxl_lora2 = gr.Dropdown(label="LoRA2", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
80
+ sdxl_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
81
+ with gr.Column():
82
+ with gr.Row():
83
+ sdxl_lora3 = gr.Dropdown(label="LoRA3", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
84
+ sdxl_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
85
+ with gr.Column():
86
+ with gr.Row():
87
+ sdxl_lora4 = gr.Dropdown(label="LoRA4", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
88
+ sdxl_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
89
+ with gr.Column():
90
+ with gr.Row():
91
+ sdxl_lora5 = gr.Dropdown(label="LoRA5", choices=sdxl_loras, value="", allow_custom_value=True, min_width=320)
92
+ sdxl_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
93
+ sdxl_run_button = gr.Button(value="Submit", variant="primary")
94
+ with gr.Tab("SD 1.5"):
95
+ with gr.Group():
96
+ with gr.Row():
97
+ sd15_presets = gr.Radio(label="Presets", choices=list(sd15_preset_dict.keys()), value=list(sd15_preset_dict.keys())[0])
98
+ with gr.Row():
99
+ sd15_mtype = gr.Textbox(value="SD 1.5", visible=False)
100
+ with gr.Row():
101
+ sd15_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value=DEFAULT_DTYPE)
102
+ with gr.Row():
103
+ sd15_ema = gr.Checkbox(label="Extract EMA", value=True, visible=True)
104
+ with gr.Row():
105
+ sd15_isize = gr.Radio(label="Image size", choices=["768", "512"], value="768")
106
+ with gr.Row():
107
+ sd15_sc = gr.Checkbox(label="Safety checker", value=False)
108
+ with gr.Accordion("Advanced settings", open=False):
109
+ with gr.Row():
110
+ sd15_vae = gr.Dropdown(label="VAE", choices=sd15_vaes, value="", allow_custom_value=True)
111
+ with gr.Row():
112
+ sd15_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
113
+ with gr.Row():
114
+ sd15_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler")
115
+ with gr.Row():
116
+ with gr.Column():
117
+ with gr.Row():
118
+ sd15_lora1 = gr.Dropdown(label="LoRA1", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
119
+ with gr.Row():
120
+ sd15_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
121
+ with gr.Row():
122
+ with gr.Column():
123
+ sd15_lora2 = gr.Dropdown(label="LoRA2", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
124
+ with gr.Row():
125
+ sd15_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
126
+ with gr.Column():
127
+ with gr.Row():
128
+ sd15_lora3 = gr.Dropdown(label="LoRA3", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
129
+ with gr.Row():
130
+ sd15_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
131
+
132
+ with gr.Column():
133
+ with gr.Row():
134
+ sd15_lora4 = gr.Dropdown(label="LoRA4", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
135
+ with gr.Row():
136
+ sd15_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
137
+ with gr.Column():
138
+ with gr.Row():
139
+ sd15_lora5 = gr.Dropdown(label="LoRA5", choices=sd15_loras, value="", allow_custom_value=True, min_width=320)
140
+ with gr.Row():
141
+ sd15_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
142
+ sd15_run_button = gr.Button(value="Submit", variant="primary")
143
+ with gr.Tab("FLUX.1"):
144
+ with gr.Group():
145
+ flux_presets = gr.Radio(label="Presets", choices=list(flux_preset_dict.keys()), value=list(flux_preset_dict.keys())[0])
146
+ flux_mtype = gr.Textbox(value="FLUX", visible=False)
147
+ with gr.Row():
148
+ flux_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value="bf16")
149
+ flux_base_repo = gr.Dropdown(label="Base repo ID", choices=FLUX_BASE_REPOS, value=FLUX_BASE_REPOS[0], allow_custom_value=True, visible=True)
150
+ with gr.Accordion("Advanced settings", open=False):
151
+ with gr.Row():
152
+ flux_vae = gr.Dropdown(label="VAE", choices=flux_vaes, value="", allow_custom_value=True)
153
+ with gr.Row():
154
+ flux_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
155
+ with gr.Row():
156
+ flux_t5 = gr.Dropdown(label="T5", choices=t5s, value="", allow_custom_value=True)
157
+ flux_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=[""], value="", visible=False)
158
+ with gr.Row():
159
+ with gr.Column():
160
+ flux_lora1 = gr.Dropdown(label="LoRA1", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
161
+ flux_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
162
+ with gr.Column():
163
+ flux_lora2 = gr.Dropdown(label="LoRA2", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
164
+ flux_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
165
+ with gr.Column():
166
+ flux_lora3 = gr.Dropdown(label="LoRA3", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
167
+ flux_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
168
+ with gr.Column():
169
+ flux_lora4 = gr.Dropdown(label="LoRA4", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
170
+ flux_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
171
+ with gr.Column():
172
+ flux_lora5 = gr.Dropdown(label="LoRA5", choices=flux_loras, value="", allow_custom_value=True, min_width=320)
173
+ flux_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
174
+ flux_run_button = gr.Button(value="Submit", variant="primary")
175
+ with gr.Tab("SD 3.5"):
176
+ with gr.Group():
177
+ with gr.Row():
178
+ sd35_presets = gr.Radio(label="Presets", choices=list(sd35_preset_dict.keys()), value=list(sd35_preset_dict.keys())[0])
179
+ with gr.Row():
180
+ sd35_mtype = gr.Textbox(value="SD 3.5", visible=False)
181
+ with gr.Row():
182
+ sd35_dtype = gr.Radio(label="Output data type", choices=get_dtypes(), value="bf16")
183
+ sd35_base_repo = gr.Dropdown(label="Base repo ID", choices=SD35_BASE_REPOS, value=SD35_BASE_REPOS[0], allow_custom_value=True, visible=True)
184
+ with gr.Accordion("Advanced settings", open=False):
185
+ with gr.Row():
186
+ sd35_vae = gr.Dropdown(label="VAE", choices=sd35_vaes, value="", allow_custom_value=True)
187
+ sd35_clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
188
+ sd35_t5 = gr.Dropdown(label="T5", choices=t5s, value="", allow_custom_value=True)
189
+ sd35_scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=[""], value="", visible=False)
190
+ with gr.Row():
191
+ with gr.Column():
192
+ with gr.Row():
193
+ sd35_lora1 = gr.Dropdown(label="LoRA1", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
194
+ sd35_lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
195
+ with gr.Column():
196
+ with gr.Row():
197
+ sd35_lora2 = gr.Dropdown(label="LoRA2", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
198
+ sd35_lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
199
+ with gr.Column():
200
+ with gr.Row():
201
+ sd35_lora3 = gr.Dropdown(label="LoRA3", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
202
+ sd35_lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
203
+ with gr.Column():
204
+ with gr.Row():
205
+ sd35_lora4 = gr.Dropdown(label="LoRA4", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
206
+ sd35_lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
207
+ with gr.Column():
208
+ with gr.Row():
209
+ sd35_lora5 = gr.Dropdown(label="LoRA5", choices=sd35_loras, value="", allow_custom_value=True, min_width=320)
210
+ sd35_lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
211
+ sd35_run_button = gr.Button(value="Submit", variant="primary")
212
+ adv_args = gr.Textbox(label="Advanced arguments", value="", visible=False)
213
+ with gr.Group():
214
+ with gr.Row():
215
+ repo_urls = gr.CheckboxGroup(visible=False, choices=[], value=[])
216
+ output_md = gr.Markdown(label="Output", value="<br><br>", elem_classes="result")
217
+ clear_button = gr.Button(value="Clear Output", variant="secondary")
218
+ gr.DuplicateButton(value="Duplicate Space")
219
+
220
+ gr.Markdown("This webui was redesigned with by [theNeofr](https://huggingface.co/theNeofr)")
221
+ gr.on(
222
+ triggers=[sdxl_run_button.click],
223
+ fn=convert_url_to_diffusers_repo,
224
+ inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
225
+ sdxl_dtype, sdxl_vae, sdxl_clip, flux_t5, sdxl_scheduler, sd15_ema, sd15_isize, sd15_sc, flux_base_repo, sdxl_mtype,
226
+ sdxl_lora1, sdxl_lora1s, sdxl_lora2, sdxl_lora2s, sdxl_lora3, sdxl_lora3s, sdxl_lora4, sdxl_lora4s, sdxl_lora5, sdxl_lora5s, adv_args],
227
+ outputs=[repo_urls, output_md],
228
+ )
229
+ sdxl_presets.change(
230
+ fn=sdxl_set_presets,
231
+ inputs=[sdxl_presets],
232
+ outputs=[sdxl_dtype, sdxl_vae, sdxl_scheduler, sdxl_lora1, sdxl_lora1s, sdxl_lora2, sdxl_lora2s, sdxl_lora3, sdxl_lora3s,
233
+ sdxl_lora4, sdxl_lora4s, sdxl_lora5, sdxl_lora5s],
234
+ queue=False,
235
+ )
236
+ gr.on(
237
+ triggers=[sd15_run_button.click],
238
+ fn=convert_url_to_diffusers_repo,
239
+ inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
240
+ sd15_dtype, sd15_vae, sd15_clip, flux_t5, sd15_scheduler, sd15_ema, sd15_isize, sd15_sc, flux_base_repo, sd15_mtype,
241
+ sd15_lora1, sd15_lora1s, sd15_lora2, sd15_lora2s, sd15_lora3, sd15_lora3s, sd15_lora4, sd15_lora4s, sd15_lora5, sd15_lora5s, adv_args],
242
+ outputs=[repo_urls, output_md],
243
+ )
244
+ sd15_presets.change(
245
+ fn=sd15_set_presets,
246
+ inputs=[sd15_presets],
247
+ outputs=[sd15_dtype, sd15_vae, sd15_scheduler, sd15_lora1, sd15_lora1s, sd15_lora2, sd15_lora2s, sd15_lora3, sd15_lora3s,
248
+ sd15_lora4, sd15_lora4s, sd15_lora5, sd15_lora5s, sd15_ema],
249
+ queue=False,
250
+ )
251
+ gr.on(
252
+ triggers=[flux_run_button.click],
253
+ fn=convert_url_to_diffusers_repo,
254
+ inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
255
+ flux_dtype, flux_vae, flux_clip, flux_t5, flux_scheduler, sd15_ema, sd15_isize, sd15_sc, flux_base_repo, flux_mtype,
256
+ flux_lora1, flux_lora1s, flux_lora2, flux_lora2s, flux_lora3, flux_lora3s, flux_lora4, flux_lora4s, flux_lora5, flux_lora5s, adv_args],
257
+ outputs=[repo_urls, output_md],
258
+ )
259
+ flux_presets.change(
260
+ fn=flux_set_presets,
261
+ inputs=[flux_presets],
262
+ outputs=[flux_dtype, flux_vae, flux_scheduler, flux_lora1, flux_lora1s, flux_lora2, flux_lora2s, flux_lora3, flux_lora3s,
263
+ flux_lora4, flux_lora4s, flux_lora5, flux_lora5s, flux_base_repo],
264
+ queue=False,
265
+ )
266
+ gr.on(
267
+ triggers=[sd35_run_button.click],
268
+ fn=convert_url_to_diffusers_repo,
269
+ inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_pr, is_upload_sf, repo_urls,
270
+ sd35_dtype, sd35_vae, sd35_clip, sd35_t5, sd35_scheduler, sd15_ema, sd15_isize, sd15_sc, sd35_base_repo, sd35_mtype,
271
+ sd35_lora1, sd35_lora1s, sd35_lora2, sd35_lora2s, sd35_lora3, sd35_lora3s, sd35_lora4, sd35_lora4s, sd35_lora5, sd35_lora5s, adv_args],
272
+ outputs=[repo_urls, output_md],
273
+ )
274
+ sd35_presets.change(
275
+ fn=sd35_set_presets,
276
+ inputs=[sd35_presets],
277
+ outputs=[sd35_dtype, sd35_vae, sd35_scheduler, sd35_lora1, sd35_lora1s, sd35_lora2, sd35_lora2s, sd35_lora3, sd35_lora3s,
278
+ sd35_lora4, sd35_lora4s, sd35_lora5, sd35_lora5s, sd35_base_repo],
279
+ queue=False,
280
+ )
281
+ clear_button.click(lambda: ([], "<br><br>"), None, [repo_urls, output_md], queue=False, show_api=False)
282
+
283
+ demo.queue()
284
+ demo.launch()