John6666 commited on
Commit
8f38b17
1 Parent(s): 1e7421b

Upload 6 files

Browse files
README.md CHANGED
@@ -1,13 +1,13 @@
1
- ---
2
- title: Download and Convert SD1.5 To Diffusers V2
3
- emoji: 🎨➡️🧨
4
- colorFrom: indigo
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 4.44.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ---
2
+ title: Download and Convert SD1.5 To Diffusers V2
3
+ emoji: 🎨➡️🧨
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 5.0.2
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -29,10 +29,14 @@ def set_presets(preset: str="Default"):
29
  return p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]
30
 
31
 
32
- css = """"""
 
 
 
 
33
 
34
- with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", css=css) as demo:
35
- gr.Markdown("# Download and convert any Stable Diffusion 1.5 / 2.0 safetensors to Diffusers and create your repo")
36
  gr.Markdown(
37
  f"""
38
  - [A CLI version of this tool (without uploading-related function) is available here](https://huggingface.co/spaces/John6666/sd-to-diffusers-v2/tree/main/local).
@@ -55,34 +59,46 @@ It saves you the trouble of typing them in.<br>
55
  """
56
  )
57
  with gr.Column():
58
- dl_url = gr.Textbox(label="URL to download", placeholder="https://huggingface.co/SG161222/RealVisXL_V4.0/blob/main/RealVisXL_V4.0.safetensors", value="", max_lines=1)
59
- hf_user = gr.Textbox(label="Your HF user ID", placeholder="username", value="", max_lines=1)
60
- hf_repo = gr.Textbox(label="New repo name", placeholder="reponame", info="If empty, auto-complete", value="", max_lines=1)
61
- hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
62
- civitai_key = gr.Textbox(label="Your Civitai API Key (Optional)", info="If you download model from Civitai...", placeholder="", value="", max_lines=1)
63
- is_upload_sf = gr.Checkbox(label="Upload single safetensors file into new repo", value=False)
64
- is_private = gr.Checkbox(label="Create private repo", value=True)
65
- presets = gr.Radio(label="Presets", choices=list(preset_dict.keys()), value="Default")
66
- with gr.Accordion("Advanced settings", open=False):
67
- is_half = gr.Checkbox(label="Half precision", value=True)
68
- model_type = gr.Radio(label="Model type", choices=["v1", "v2"], value="v1")
69
- sample_size = gr.Radio(label="Sample size (px)", choices=[512, 768], value=768)
70
- ema = gr.Radio(label="Extract EMA or non-EMA?", choices=["ema", "non-ema"], value="ema")
71
- vae = gr.Dropdown(label="VAE", choices=vaes, value="", allow_custom_value=True)
72
- scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler")
73
- lora1 = gr.Dropdown(label="LoRA1", choices=loras, value="", allow_custom_value=True)
74
- lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
75
- lora2 = gr.Dropdown(label="LoRA2", choices=loras, value="", allow_custom_value=True)
76
- lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
77
- lora3 = gr.Dropdown(label="LoRA3", choices=loras, value="", allow_custom_value=True)
78
- lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
79
- lora4 = gr.Dropdown(label="LoRA4", choices=loras, value="", allow_custom_value=True)
80
- lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
81
- lora5 = gr.Dropdown(label="LoRA5", choices=loras, value="", allow_custom_value=True)
82
- lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
 
 
 
 
 
 
 
 
 
 
 
 
83
  run_button = gr.Button(value="Submit")
84
  repo_urls = gr.CheckboxGroup(visible=False, choices=[], value=None)
85
- output_md = gr.Markdown(label="Output")
86
  gr.DuplicateButton(value="Duplicate Space")
87
 
88
  gr.on(
 
29
  return p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]
30
 
31
 
32
+ css = """
33
+ .title { font-size: 3em; align-items: center; text-align: center; }
34
+ .info { align-items: center; text-align: center; }
35
+ .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; }
36
+ """
37
 
38
+ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css, delete_cache=(60, 3600)) as demo:
39
+ gr.Markdown("# Download and convert any Stable Diffusion 1.5 / 2.0 safetensors to Diffusers and create your repo", elem_classes="title")
40
  gr.Markdown(
41
  f"""
42
  - [A CLI version of this tool (without uploading-related function) is available here](https://huggingface.co/spaces/John6666/sd-to-diffusers-v2/tree/main/local).
 
59
  """
60
  )
61
  with gr.Column():
62
+ with gr.Group():
63
+ dl_url = gr.Textbox(label="URL to download", placeholder="https://huggingface.co/SG161222/RealVisXL_V4.0/blob/main/RealVisXL_V4.0.safetensors", value="", max_lines=1)
64
+ with gr.Row():
65
+ hf_user = gr.Textbox(label="Your HF user ID", placeholder="username", value="", max_lines=1)
66
+ hf_repo = gr.Textbox(label="New repo name", placeholder="reponame", info="If empty, auto-complete", value="", max_lines=1)
67
+ with gr.Row():
68
+ hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
69
+ civitai_key = gr.Textbox(label="Your Civitai API Key (Optional)", info="If you download model from Civitai...", placeholder="", value="", max_lines=1)
70
+ with gr.Row():
71
+ is_upload_sf = gr.Checkbox(label="Upload single safetensors file into new repo", value=False)
72
+ is_private = gr.Checkbox(label="Create private repo", value=True)
73
+ presets = gr.Radio(label="Presets", choices=list(preset_dict.keys()), value="Default")
74
+ with gr.Accordion("Advanced settings", open=False):
75
+ with gr.Row():
76
+ is_half = gr.Checkbox(label="Half precision", value=True)
77
+ model_type = gr.Radio(label="Model type", choices=["v1", "v2"], value="v1")
78
+ sample_size = gr.Radio(label="Sample size (px)", choices=[512, 768], value=768)
79
+ ema = gr.Radio(label="Extract EMA or non-EMA?", choices=["ema", "non-ema"], value="ema")
80
+ with gr.Row():
81
+ vae = gr.Dropdown(label="VAE", choices=vaes, value="", allow_custom_value=True)
82
+ scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler")
83
+ with gr.Row():
84
+ with gr.Column():
85
+ lora1 = gr.Dropdown(label="LoRA1", choices=loras, value="", allow_custom_value=True, min_width=320)
86
+ lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
87
+ with gr.Column():
88
+ lora2 = gr.Dropdown(label="LoRA2", choices=loras, value="", allow_custom_value=True, min_width=320)
89
+ lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
90
+ with gr.Column():
91
+ lora3 = gr.Dropdown(label="LoRA3", choices=loras, value="", allow_custom_value=True, min_width=320)
92
+ lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
93
+ with gr.Column():
94
+ lora4 = gr.Dropdown(label="LoRA4", choices=loras, value="", allow_custom_value=True, min_width=320)
95
+ lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
96
+ with gr.Column():
97
+ lora5 = gr.Dropdown(label="LoRA5", choices=loras, value="", allow_custom_value=True, min_width=320)
98
+ lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
99
  run_button = gr.Button(value="Submit")
100
  repo_urls = gr.CheckboxGroup(visible=False, choices=[], value=None)
101
+ output_md = gr.Markdown(label="Output", value="<br><br>", elem_classes="result")
102
  gr.DuplicateButton(value="Duplicate Space")
103
 
104
  gr.on(
convert_url_to_diffusers_sd.py CHANGED
@@ -194,7 +194,7 @@ tags:
194
 
195
 
196
  def fuse_loras(pipe, civitai_key="", lora_dict={}, temp_dir="."):
197
- if not lora_dict or not isinstance(lora_dict, dict): return
198
  a_list = []
199
  w_list = []
200
  for k, v in lora_dict.items():
@@ -208,7 +208,7 @@ def fuse_loras(pipe, civitai_key="", lora_dict={}, temp_dir="."):
208
  pipe.load_lora_weights(new_lora_file, weight_name = w_name, adapter_name = a_name)
209
  a_list.append(a_name)
210
  w_list.append(v)
211
- if not a_list: return
212
  pipe.set_adapters(a_list, adapter_weights=w_list)
213
  pipe.fuse_lora(adapter_names=a_list, lora_scale=1.0)
214
  pipe.unload_lora_weights()
 
194
 
195
 
196
  def fuse_loras(pipe, civitai_key="", lora_dict={}, temp_dir="."):
197
+ if not lora_dict or not isinstance(lora_dict, dict): return pipe
198
  a_list = []
199
  w_list = []
200
  for k, v in lora_dict.items():
 
208
  pipe.load_lora_weights(new_lora_file, weight_name = w_name, adapter_name = a_name)
209
  a_list.append(a_name)
210
  w_list.append(v)
211
+ if not a_list: return pipe
212
  pipe.set_adapters(a_list, adapter_weights=w_list)
213
  pipe.fuse_lora(adapter_names=a_list, lora_scale=1.0)
214
  pipe.unload_lora_weights()
convert_url_to_diffusers_sd_gr.py CHANGED
@@ -223,7 +223,7 @@ tags:
223
 
224
 
225
  def fuse_loras(pipe, lora_dict={}, temp_dir=".", civitai_key="", hf_token=""):
226
- if not lora_dict or not isinstance(lora_dict, dict): return
227
  a_list = []
228
  w_list = []
229
  for k, v in lora_dict.items():
@@ -237,7 +237,7 @@ def fuse_loras(pipe, lora_dict={}, temp_dir=".", civitai_key="", hf_token=""):
237
  pipe.load_lora_weights(new_lora_file, weight_name = w_name, adapter_name = a_name)
238
  a_list.append(a_name)
239
  w_list.append(v)
240
- if not a_list: return
241
  pipe.set_adapters(a_list, adapter_weights=w_list)
242
  pipe.fuse_lora(adapter_names=a_list, lora_scale=1.0)
243
  pipe.unload_lora_weights()
 
223
 
224
 
225
  def fuse_loras(pipe, lora_dict={}, temp_dir=".", civitai_key="", hf_token=""):
226
+ if not lora_dict or not isinstance(lora_dict, dict): return pipe
227
  a_list = []
228
  w_list = []
229
  for k, v in lora_dict.items():
 
237
  pipe.load_lora_weights(new_lora_file, weight_name = w_name, adapter_name = a_name)
238
  a_list.append(a_name)
239
  w_list.append(v)
240
+ if not a_list: return pipe
241
  pipe.set_adapters(a_list, adapter_weights=w_list)
242
  pipe.fuse_lora(adapter_names=a_list, lora_scale=1.0)
243
  pipe.unload_lora_weights()
local/convert_url_to_diffusers_sd.py CHANGED
@@ -194,7 +194,7 @@ tags:
194
 
195
 
196
  def fuse_loras(pipe, civitai_key="", lora_dict={}, temp_dir="."):
197
- if not lora_dict or not isinstance(lora_dict, dict): return
198
  a_list = []
199
  w_list = []
200
  for k, v in lora_dict.items():
@@ -208,7 +208,7 @@ def fuse_loras(pipe, civitai_key="", lora_dict={}, temp_dir="."):
208
  pipe.load_lora_weights(new_lora_file, weight_name = w_name, adapter_name = a_name)
209
  a_list.append(a_name)
210
  w_list.append(v)
211
- if not a_list: return
212
  pipe.set_adapters(a_list, adapter_weights=w_list)
213
  pipe.fuse_lora(adapter_names=a_list, lora_scale=1.0)
214
  pipe.unload_lora_weights()
 
194
 
195
 
196
  def fuse_loras(pipe, civitai_key="", lora_dict={}, temp_dir="."):
197
+ if not lora_dict or not isinstance(lora_dict, dict): return pipe
198
  a_list = []
199
  w_list = []
200
  for k, v in lora_dict.items():
 
208
  pipe.load_lora_weights(new_lora_file, weight_name = w_name, adapter_name = a_name)
209
  a_list.append(a_name)
210
  w_list.append(v)
211
+ if not a_list: return pipe
212
  pipe.set_adapters(a_list, adapter_weights=w_list)
213
  pipe.fuse_lora(adapter_names=a_list, lora_scale=1.0)
214
  pipe.unload_lora_weights()