John6666 commited on
Commit
5f6fe85
1 Parent(s): 3bd37b4

Upload 6 files

Browse files
README.md CHANGED
@@ -1,13 +1,13 @@
1
- ---
2
- title: Download and Convert SDXL To Diffusers V2 (Private Repo version)
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 SDXL To Diffusers V2 (Private Repo version)
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
@@ -46,10 +46,14 @@ def set_presets(preset: str="Default"):
46
  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]
47
 
48
 
49
- css = """"""
 
 
 
 
50
 
51
- with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", css=css) as demo:
52
- gr.Markdown("# Download and convert any Stable Diffusion XL safetensors to Diffusers and create your repo")
53
  gr.Markdown(
54
  f"""
55
  - [A CLI version of this tool (without uploading-related function) is available here](https://huggingface.co/spaces/John6666/sdxl-to-diffusers-v2/tree/main/local).
@@ -72,31 +76,42 @@ It saves you the trouble of typing them in.<br>
72
  """
73
  )
74
  with gr.Column():
75
- 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", value="", max_lines=1)
76
- hf_user = gr.Textbox(label="Your HF user ID", placeholder="username", value="", max_lines=1)
77
- hf_repo = gr.Textbox(label="New repo name", placeholder="reponame", info="If empty, auto-complete", value="", max_lines=1)
78
- hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
79
- civitai_key = gr.Textbox(label="Your Civitai API Key (Optional)", info="If you download model from Civitai...", placeholder="", value="", max_lines=1)
80
- is_upload_sf = gr.Checkbox(label="Upload single safetensors file into new repo", value=False)
81
- is_private = gr.Checkbox(label="Create private repo", value=True, visible=False)
82
- presets = gr.Radio(label="Presets", choices=list(preset_dict.keys()), value="Default")
83
- with gr.Accordion("Advanced settings", open=False):
84
- is_half = gr.Checkbox(label="Half precision", value=True)
85
- vae = gr.Dropdown(label="VAE", choices=vaes, value="", allow_custom_value=True)
86
- scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler a")
87
- lora1 = gr.Dropdown(label="LoRA1", choices=loras, value="", allow_custom_value=True)
88
- lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
89
- lora2 = gr.Dropdown(label="LoRA2", choices=loras, value="", allow_custom_value=True)
90
- lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
91
- lora3 = gr.Dropdown(label="LoRA3", choices=loras, value="", allow_custom_value=True)
92
- lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
93
- lora4 = gr.Dropdown(label="LoRA4", choices=loras, value="", allow_custom_value=True)
94
- lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
95
- lora5 = gr.Dropdown(label="LoRA5", choices=loras, value="", allow_custom_value=True)
96
- lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
 
 
 
 
 
 
 
 
 
 
 
97
  run_button = gr.Button(value="Submit")
98
  repo_urls = gr.CheckboxGroup(visible=False, choices=[], value=None)
99
- output_md = gr.Markdown(label="Output")
100
  gr.DuplicateButton(value="Duplicate Space")
101
 
102
  gr.on(
 
46
  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]
47
 
48
 
49
+ css = """
50
+ .title { font-size: 3em; align-items: center; text-align: center; }
51
+ .info { align-items: center; text-align: center; }
52
+ .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; }
53
+ """
54
 
55
+ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css, delete_cache=(60, 3600)) as demo:
56
+ gr.Markdown("# Download and convert any Stable Diffusion XL safetensors to Diffusers and create your repo", elem_classes="title")
57
  gr.Markdown(
58
  f"""
59
  - [A CLI version of this tool (without uploading-related function) is available here](https://huggingface.co/spaces/John6666/sdxl-to-diffusers-v2/tree/main/local).
 
76
  """
77
  )
78
  with gr.Column():
79
+ with gr.Group():
80
+ 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", value="", max_lines=1)
81
+ with gr.Row():
82
+ hf_user = gr.Textbox(label="Your HF user ID", placeholder="username", value="", max_lines=1)
83
+ hf_repo = gr.Textbox(label="New repo name", placeholder="reponame", info="If empty, auto-complete", value="", max_lines=1)
84
+ with gr.Row():
85
+ hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
86
+ civitai_key = gr.Textbox(label="Your Civitai API Key (Optional)", info="If you download model from Civitai...", placeholder="", value="", max_lines=1)
87
+ with gr.Row():
88
+ is_upload_sf = gr.Checkbox(label="Upload single safetensors file into new repo", value=False)
89
+ is_private = gr.Checkbox(label="Create private repo", value=True)
90
+ presets = gr.Radio(label="Presets", choices=list(preset_dict.keys()), value="Default")
91
+ with gr.Accordion("Advanced settings", open=False):
92
+ is_half = gr.Checkbox(label="Half precision", value=True)
93
+ with gr.Row():
94
+ vae = gr.Dropdown(label="VAE", choices=vaes, value="", allow_custom_value=True)
95
+ scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler a")
96
+ with gr.Row():
97
+ with gr.Column():
98
+ lora1 = gr.Dropdown(label="LoRA1", choices=loras, value="", allow_custom_value=True, min_width=320)
99
+ lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
100
+ with gr.Column():
101
+ lora2 = gr.Dropdown(label="LoRA2", choices=loras, value="", allow_custom_value=True, min_width=320)
102
+ lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
103
+ with gr.Column():
104
+ lora3 = gr.Dropdown(label="LoRA3", choices=loras, value="", allow_custom_value=True, min_width=320)
105
+ lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
106
+ with gr.Column():
107
+ lora4 = gr.Dropdown(label="LoRA4", choices=loras, value="", allow_custom_value=True, min_width=320)
108
+ lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
109
+ with gr.Column():
110
+ lora5 = gr.Dropdown(label="LoRA5", choices=loras, value="", allow_custom_value=True, min_width=320)
111
+ lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
112
  run_button = gr.Button(value="Submit")
113
  repo_urls = gr.CheckboxGroup(visible=False, choices=[], value=None)
114
+ output_md = gr.Markdown(label="Output", value="<br><br>", elem_classes="result")
115
  gr.DuplicateButton(value="Duplicate Space")
116
 
117
  gr.on(
convert_url_to_diffusers_sdxl.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_sdxl_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_sdxl.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()