pongping camenduru commited on
Commit
6110960
0 Parent(s):

Duplicate from camenduru/converter

Browse files

Co-authored-by: camenduru <camenduru@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. README.md +12 -0
  3. app.py +552 -0
  4. packages.txt +1 -0
  5. requirements.txt +12 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Converter
3
+ emoji: ♻
4
+ colorFrom: green
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 3.10.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: camenduru/converter
12
+ ---
app.py ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, gdown, gc
2
+ import numpy as np
3
+ import gradio as gr
4
+ from diffusers import FlaxStableDiffusionPipeline, StableDiffusionPipeline
5
+ import torch
6
+ from safetensors.torch import save_file, load_file
7
+ from huggingface_hub import model_info, create_repo, create_branch, upload_folder
8
+ from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
9
+
10
+ def download_ckpt(ckpt_url):
11
+ if "drive.google.com" in ckpt_url:
12
+ gdown.download(url=ckpt_url, output="model.ckpt", quiet=False, fuzzy=True)
13
+ else:
14
+ os.system(f"wget {ckpt_url} -O model.ckpt")
15
+ return "download ckpt done!"
16
+
17
+ def download_vae(vae_url):
18
+ if "drive.google.com" in vae_url:
19
+ gdown.download(url=vae_url, output="vae.ckpt", quiet=False, fuzzy=True)
20
+ else:
21
+ os.system(f"wget {vae_url} -O vae.ckpt")
22
+ return "download vae done!"
23
+
24
+ def to_pt():
25
+ os.system("wget -q https://raw.githubusercontent.com/huggingface/diffusers/v0.13.1/scripts/convert_original_stable_diffusion_to_diffusers.py")
26
+ os.system(f"python3 convert_original_stable_diffusion_to_diffusers.py --checkpoint_path model.ckpt --dump_path pt")
27
+ return "convert to pt done!"
28
+
29
+ def from_safetensors_to_pt():
30
+ os.system("wget -q https://raw.githubusercontent.com/huggingface/diffusers/v0.13.1/scripts/convert_original_stable_diffusion_to_diffusers.py")
31
+ os.system(f"python3 convert_original_stable_diffusion_to_diffusers.py --from_safetensors --checkpoint_path model.safetensors --dump_path pt")
32
+ return "convert to pt done!"
33
+
34
+ def from_ckpt_to_safetensors():
35
+ os.system("wget -q https://raw.githubusercontent.com/huggingface/diffusers/v0.13.1/scripts/convert_original_stable_diffusion_to_diffusers.py")
36
+ os.system(f"python3 convert_original_stable_diffusion_to_diffusers.py --checkpoint_path model.ckpt --to_safetensors --dump_path safetensors")
37
+ return "convert to safetensors done!"
38
+
39
+ def from_safetensors_to_safetensors():
40
+ os.system("wget -q https://raw.githubusercontent.com/huggingface/diffusers/v0.13.1/scripts/convert_original_stable_diffusion_to_diffusers.py")
41
+ os.system(f"python3 convert_original_stable_diffusion_to_diffusers.py --from_safetensors --checkpoint_path model.safetensors --to_safetensors --dump_path safetensors")
42
+ return "convert to safetensors done!"
43
+
44
+ def from_safetensors_to_emaonly(safetensors_emaonly_name):
45
+ os.system("mkdir safetensors")
46
+ tensors = load_file("model.safetensors")
47
+ filtered_only_ema = {k: v for k, v in tensors.items() if not k.startswith("model.")}
48
+ save_file(filtered_only_ema, f"safetensors/{safetensors_emaonly_name}-emaonly.safetensors")
49
+ return "convert to safetensors emaonly done!"
50
+
51
+ def swap_ckpt_vae(ckpt_name):
52
+ os.system("mkdir ckpt")
53
+ model = torch.load("model.ckpt", map_location="cpu")
54
+ if "state_dict" in model:
55
+ sd = model["state_dict"]
56
+ else:
57
+ sd = model
58
+ full_model = False
59
+ vae_model = torch.load("vae.ckpt", map_location="cpu")
60
+ vae_sd = vae_model['state_dict']
61
+ for vae_key in vae_sd:
62
+ if vae_key.startswith("first_stage_model."):
63
+ full_model = True
64
+ break
65
+ for vae_key in vae_sd:
66
+ sd_key = vae_key
67
+ if full_model:
68
+ if not sd_key.startswith("first_stage_model."):
69
+ continue
70
+ else:
71
+ if sd_key not in sd:
72
+ sd_key = "first_stage_model." + sd_key
73
+ if sd_key not in sd:
74
+ continue
75
+ sd[sd_key] = vae_sd[vae_key]
76
+ torch.save(model, f"ckpt/{ckpt_name}-vae-swapped.ckpt")
77
+ del model
78
+ del vae_model
79
+ del sd
80
+ del vae_sd
81
+ gc.collect()
82
+ return "swap ckpt vae done!"
83
+
84
+ def push_pt(model_to, token, branch):
85
+ try:
86
+ repo_exists = True
87
+ r_info = model_info(model_to, token=token)
88
+ except RepositoryNotFoundError:
89
+ repo_exists = False
90
+ finally:
91
+ if repo_exists:
92
+ print(r_info)
93
+ else:
94
+ create_repo(model_to, private=True, token=token)
95
+ try:
96
+ branch_exists = True
97
+ b_info = model_info(model_to, revision=branch, token=token)
98
+ except RevisionNotFoundError:
99
+ branch_exists = False
100
+ finally:
101
+ if branch_exists:
102
+ print(b_info)
103
+ else:
104
+ create_branch(model_to, branch=branch, token=token)
105
+ upload_folder(folder_path="pt", path_in_repo="", revision=branch, repo_id=model_to, commit_message=f"pt - camenduru/converter", token=token)
106
+ return "push pt done!"
107
+
108
+ def delete_pt():
109
+ os.system(f"rm -rf pt")
110
+ return "delete pt done!"
111
+
112
+ def clone_pt(model_url):
113
+ os.system("git lfs install")
114
+ os.system(f"git clone https://huggingface.co/{model_url} pt")
115
+ return "clone pt done!"
116
+
117
+ def pt_to_flax():
118
+ pipe, params = FlaxStableDiffusionPipeline.from_pretrained("pt", from_pt=True)
119
+ pipe.save_pretrained("flax", params=params)
120
+ return "convert to flax done!"
121
+
122
+ def push_flax(model_to, token, branch):
123
+ try:
124
+ repo_exists = True
125
+ r_info = model_info(model_to, token=token)
126
+ except RepositoryNotFoundError:
127
+ repo_exists = False
128
+ finally:
129
+ if repo_exists:
130
+ print(r_info)
131
+ else:
132
+ create_repo(model_to, private=True, token=token)
133
+ try:
134
+ branch_exists = True
135
+ b_info = model_info(model_to, revision=branch, token=token)
136
+ except RevisionNotFoundError:
137
+ branch_exists = False
138
+ finally:
139
+ if branch_exists:
140
+ print(b_info)
141
+ else:
142
+ create_branch(model_to, branch=branch, token=token)
143
+ upload_folder(folder_path="flax", path_in_repo="", revision=branch, repo_id=model_to, commit_message=f"flax - camenduru/converter", token=token)
144
+ return "push flax done!"
145
+
146
+ def delete_flax():
147
+ os.system(f"rm -rf flax")
148
+ return "delete flax done!"
149
+
150
+ def flax_to_pt():
151
+ pipe = StableDiffusionPipeline.from_pretrained("flax", from_flax=True, safety_checker=None)
152
+ pipe.save_pretrained("pt")
153
+ return "convert to pt done!"
154
+
155
+ def clone_flax(model_url):
156
+ os.system("git lfs install")
157
+ os.system(f"git clone https://huggingface.co/{model_url} flax")
158
+ return "clone flax done!"
159
+
160
+ def to_ckpt(ckpt_name):
161
+ os.system("wget -q https://raw.githubusercontent.com/huggingface/diffusers/v0.13.1/scripts/convert_diffusers_to_original_stable_diffusion.py")
162
+ os.system("mkdir ckpt")
163
+ os.system(f"python3 convert_diffusers_to_original_stable_diffusion.py --model_path pt --checkpoint_path ckpt/{ckpt_name}.ckpt")
164
+ return "convert to ckpt done!"
165
+
166
+ def push_ckpt(model_to, token, branch):
167
+ try:
168
+ repo_exists = True
169
+ r_info = model_info(model_to, token=token)
170
+ except RepositoryNotFoundError:
171
+ repo_exists = False
172
+ finally:
173
+ if repo_exists:
174
+ print(r_info)
175
+ else:
176
+ create_repo(model_to, private=True, token=token)
177
+ try:
178
+ branch_exists = True
179
+ b_info = model_info(model_to, revision=branch, token=token)
180
+ except RevisionNotFoundError:
181
+ branch_exists = False
182
+ finally:
183
+ if branch_exists:
184
+ print(b_info)
185
+ else:
186
+ create_branch(model_to, branch=branch, token=token)
187
+ upload_folder(folder_path="ckpt", path_in_repo="", revision=branch, repo_id=model_to, commit_message=f"ckpt - camenduru/converter", token=token)
188
+ return "push ckpt done!"
189
+
190
+ def delete_ckpt():
191
+ os.system(f"rm -rf ckpt")
192
+ return "delete ckpt done!"
193
+
194
+ def to_safetensors(safetensors_name):
195
+ os.system("mkdir safetensors")
196
+ weights = torch.load("model.ckpt", map_location="cpu")
197
+ if "state_dict" in weights:
198
+ weights = weights["state_dict"]
199
+ save_file(weights, f"safetensors/{safetensors_name}.safetensors")
200
+ return "convert to safetensors done!"
201
+
202
+ def push_safetensors(model_to, token, branch):
203
+ try:
204
+ repo_exists = True
205
+ r_info = model_info(model_to, token=token)
206
+ except RepositoryNotFoundError:
207
+ repo_exists = False
208
+ finally:
209
+ if repo_exists:
210
+ print(r_info)
211
+ else:
212
+ create_repo(model_to, private=True, token=token)
213
+ try:
214
+ branch_exists = True
215
+ b_info = model_info(model_to, revision=branch, token=token)
216
+ except RevisionNotFoundError:
217
+ branch_exists = False
218
+ finally:
219
+ if branch_exists:
220
+ print(b_info)
221
+ else:
222
+ create_branch(model_to, branch=branch, token=token)
223
+ upload_folder(folder_path="safetensors", path_in_repo="", revision=branch, repo_id=model_to, commit_message=f"safetensors - camenduru/converter", token=token)
224
+ return "push safetensors done!"
225
+
226
+ def delete_safetensors():
227
+ os.system(f"rm -rf safetensors")
228
+ return "delete safetensors done!"
229
+
230
+ def download_safetensors(safetensors_url):
231
+ if "drive.google.com" in safetensors_url:
232
+ gdown.download(url=ckpt_url, output="model.safetensors", quiet=False, fuzzy=True)
233
+ else:
234
+ os.system(f"wget {safetensors_url} -O model.safetensors")
235
+ return "download safetensors done!"
236
+
237
+ def from_safetensors_to_ckpt(ckpt_name):
238
+ weights = load_file("model.safetensors", device="cpu")
239
+ os.system("mkdir ckpt")
240
+ torch.save(weights, f"ckpt/{ckpt_name}.ckpt")
241
+ return "convert to ckpt done!"
242
+
243
+ def delete_all():
244
+ delete_pt()
245
+ delete_flax()
246
+ delete_ckpt()
247
+ delete_safetensors()
248
+ return "delete all done!"
249
+
250
+ block = gr.Blocks()
251
+
252
+ with block:
253
+ gr.Markdown(
254
+ """
255
+ ## 🚨 Please first click delete all button 🚨 Thanks to 🤗 ❤ Now with CPU Upgrade! 🎉 <a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/camenduru/converter?duplicate=true"><img style="margin: 0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a>&nbsp;&nbsp;<a style="display:inline-block" href="https://github.com/camenduru/converter-colab" target="_blank"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" style="margin-bottom: 0px; margin-top: 0px;"></a>&nbsp;&nbsp;<a style="display:inline-block" href="https://patreon.com/camenduru"><img style="margin: 0" alt="Become A Patreon" src="https://badgen.net/badge/become/a%20patron/F96854"></a>&nbsp;&nbsp;<a style="display:inline-block" href="https://ko-fi.com/camenduru" target="_blank"><img style="margin: 0" alt="Buy a Coffee" src="https://badgen.net/badge/buy/a%20coffee/green?icon=kofi"></a>
256
+ 🐣 Please follow me for new updates <a href="https://twitter.com/camenduru">https://twitter.com/camenduru</a>
257
+ """)
258
+ with gr.Row().style(equal_height=True):
259
+ btn_delete_all = gr.Button("Delete ALL")
260
+ out_all = gr.Textbox(show_label=False)
261
+ btn_delete_all.click(delete_all, outputs=out_all)
262
+ gr.Markdown(
263
+ """
264
+ ### ckpt to diffusers pytorch
265
+ ckpt_url = <small>https://huggingface.co/prompthero/openjourney/resolve/main/mdjrny-v4.ckpt or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/5616?type=Model&format=PickleTensor"</small><br />
266
+ pt_model_to = camenduru/openjourney <br />
267
+ branch = main <br />
268
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write
269
+ """)
270
+ with gr.Group():
271
+ with gr.Box():
272
+ with gr.Row().style(equal_height=True):
273
+ text_ckpt_url = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_url")
274
+ text_pt_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="pt_model_to")
275
+ text_pt_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="pt_branch")
276
+ text_pt_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
277
+ out_pt = gr.Textbox(show_label=False)
278
+ with gr.Row().style(equal_height=True):
279
+ btn_download_ckpt = gr.Button("Download CKPT")
280
+ btn_to_pt = gr.Button("Convert to Diffusers PT")
281
+ btn_push_pt = gr.Button("Push Diffusers PT to 🤗")
282
+ btn_delete_pt = gr.Button("Delete Diffusers PT")
283
+ btn_download_ckpt.click(download_ckpt, inputs=[text_ckpt_url], outputs=out_pt)
284
+ btn_to_pt.click(to_pt, outputs=out_pt)
285
+ btn_push_pt.click(push_pt, inputs=[text_pt_model_to, text_pt_token, text_pt_branch], outputs=out_pt)
286
+ btn_delete_pt.click(delete_pt, outputs=out_pt)
287
+ gr.Markdown(
288
+ """
289
+ ### ckpt to diffusers safetensors
290
+ ckpt_url = <small>https://huggingface.co/prompthero/openjourney/resolve/main/mdjrny-v4.ckpt or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/5616?type=Model&format=PickleTensor"</small><br />
291
+ safetensors_pt_model_to = camenduru/openjourney <br />
292
+ branch = main <br />
293
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write
294
+ """)
295
+ with gr.Group():
296
+ with gr.Box():
297
+ with gr.Row().style(equal_height=True):
298
+ text_ckpt_to_safetensors_url = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_url")
299
+ text_ckpt_to_safetensors_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_pt_model_to")
300
+ text_ckpt_to_safetensors_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="safetensors_branch")
301
+ text_ckpt_to_safetensors_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
302
+ out_ckpt_to_safetensors = gr.Textbox(show_label=False)
303
+ with gr.Row().style(equal_height=True):
304
+ btn_download_ckpt_to_safetensors = gr.Button("Download CKPT")
305
+ btn_ckpt_to_safetensors = gr.Button("Convert to Diffusers Safetensors")
306
+ btn_push_ckpt_to_safetensors = gr.Button("Push Diffusers Safetensors to 🤗")
307
+ btn_delete_ckpt_to_safetensors = gr.Button("Delete Diffusers Safetensors")
308
+ btn_download_ckpt_to_safetensors.click(download_ckpt, inputs=[text_ckpt_to_safetensors_url], outputs=out_ckpt_to_safetensors)
309
+ btn_ckpt_to_safetensors.click(from_ckpt_to_safetensors, outputs=out_ckpt_to_safetensors)
310
+ btn_push_ckpt_to_safetensors.click(push_safetensors, inputs=[text_ckpt_to_safetensors_model_to, text_ckpt_to_safetensors_token, text_ckpt_to_safetensors_branch], outputs=out_ckpt_to_safetensors)
311
+ btn_delete_ckpt_to_safetensors.click(delete_safetensors, outputs=out_ckpt_to_safetensors)
312
+ gr.Markdown(
313
+ """
314
+ ### safetensors to diffusers pytorch
315
+ safetensors_url = <small>https://huggingface.co/prompthero/openjourney/resolve/main/mdjrny-v4.safetensors or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/5616?type=Model&format=SafeTensor"</small><br />
316
+ pt_model_to = camenduru/openjourney <br />
317
+ branch = main <br />
318
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write
319
+ """)
320
+ with gr.Group():
321
+ with gr.Box():
322
+ with gr.Row().style(equal_height=True):
323
+ text_safetensors_to_pt_url = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_url")
324
+ text_safetensors_to_pt_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="pt_model_to")
325
+ text_safetensors_to_pt_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="pt_branch")
326
+ text_safetensors_to_pt_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
327
+ out_safetensors_to_pt = gr.Textbox(show_label=False)
328
+ with gr.Row().style(equal_height=True):
329
+ btn_download_safetensors_to_pt = gr.Button("Download Safetensors")
330
+ btn_safetensors_to_pt = gr.Button("Convert to Diffusers PT")
331
+ btn_push_safetensors_to_pt = gr.Button("Push Diffusers PT to 🤗")
332
+ btn_delete_safetensors_to_pt = gr.Button("Delete Diffusers PT")
333
+ btn_download_safetensors_to_pt.click(download_safetensors, inputs=[text_safetensors_to_pt_url], outputs=out_safetensors_to_pt)
334
+ btn_safetensors_to_pt.click(from_safetensors_to_pt, outputs=out_safetensors_to_pt)
335
+ btn_push_safetensors_to_pt.click(push_pt, inputs=[text_safetensors_to_pt_model_to, text_safetensors_to_pt_token, text_safetensors_to_pt_branch], outputs=out_safetensors_to_pt)
336
+ btn_delete_safetensors_to_pt.click(delete_pt, outputs=out_safetensors_to_pt)
337
+ gr.Markdown(
338
+ """
339
+ ### safetensors to diffusers safetensors
340
+ safetensors_url = <small>https://huggingface.co/prompthero/openjourney/resolve/main/mdjrny-v4.ckpt or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/5616?type=Model&format=SafeTensor"</small><br />
341
+ safetensors_model_to = camenduru/openjourney <br />
342
+ branch = main <br />
343
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write
344
+ """)
345
+ with gr.Group():
346
+ with gr.Box():
347
+ with gr.Row().style(equal_height=True):
348
+ text_safetensors_to_safetensors_url = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_url")
349
+ text_safetensors_to_safetensors_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_model_to")
350
+ text_safetensors_to_safetensors_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="pt_branch")
351
+ text_safetensors_to_safetensors_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
352
+ out_safetensors_to_safetensors = gr.Textbox(show_label=False)
353
+ with gr.Row().style(equal_height=True):
354
+ btn_download_safetensors_to_safetensors = gr.Button("Download Safetensors")
355
+ btn_safetensors_to_safetensors = gr.Button("Convert to Diffusers Safetensors")
356
+ btn_push_safetensors_to_safetensors = gr.Button("Push Diffusers Safetensors to 🤗")
357
+ btn_delete_safetensors_to_safetensors = gr.Button("Delete Diffusers Safetensors")
358
+ btn_download_safetensors_to_safetensors.click(download_safetensors, inputs=[text_safetensors_to_safetensors_url], outputs=out_safetensors_to_safetensors)
359
+ btn_safetensors_to_safetensors.click(from_safetensors_to_safetensors, outputs=out_safetensors_to_safetensors)
360
+ btn_push_safetensors_to_safetensors.click(push_safetensors, inputs=[text_safetensors_to_safetensors_model_to, text_safetensors_to_safetensors_token, text_safetensors_to_safetensors_branch], outputs=out_safetensors_to_safetensors)
361
+ btn_delete_safetensors_to_safetensors.click(delete_safetensors, outputs=out_safetensors_to_safetensors)
362
+ gr.Markdown(
363
+ """
364
+ ### diffusers pytorch to diffusers flax <br />
365
+ pt_model_from = dreamlike-art/dreamlike-diffusion-1.0 <br />
366
+ flax_model_to = camenduru/dreamlike-diffusion-1.0 <br />
367
+ branch = flax <br />
368
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write <br />
369
+ """)
370
+ with gr.Group():
371
+ with gr.Box():
372
+ with gr.Row().style(equal_height=True):
373
+ text_pt_model_from = gr.Textbox(show_label=False, max_lines=1, placeholder="pt_model_from")
374
+ text_flax_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="flax_model_to")
375
+ text_flax_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="flax_branch")
376
+ text_flax_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
377
+ out_flax = gr.Textbox(show_label=False)
378
+ with gr.Row().style(equal_height=True):
379
+ btn_clone_pt = gr.Button("Clone Diffusers PT from 🤗")
380
+ btn_to_flax = gr.Button("Convert to Diffusers Flax")
381
+ btn_push_flax = gr.Button("Push Diffusers Flax to 🤗")
382
+ btn_delete_flax = gr.Button("Delete Diffusers Flax")
383
+ btn_clone_pt.click(clone_pt, inputs=[text_pt_model_from], outputs=out_flax)
384
+ btn_to_flax.click(pt_to_flax, outputs=out_flax)
385
+ btn_push_flax.click(push_flax, inputs=[text_flax_model_to, text_flax_token, text_flax_branch], outputs=out_flax)
386
+ btn_delete_flax.click(delete_flax, outputs=out_flax)
387
+ gr.Markdown(
388
+ """
389
+ ### diffusers flax to diffusers pytorch <br />
390
+ flax_model_from = flax/mo-di-diffusion <br />
391
+ pt_model_to = camenduru/mo-di-diffusion <br />
392
+ branch = pt <br />
393
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write <br />
394
+ """)
395
+ with gr.Group():
396
+ with gr.Box():
397
+ with gr.Row().style(equal_height=True):
398
+ text_flax_model_from = gr.Textbox(show_label=False, max_lines=1, placeholder="flax_model_from")
399
+ text_pt_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="pt_model_to")
400
+ text_pt_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="pt_branch")
401
+ text_pt_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
402
+ out_pt = gr.Textbox(show_label=False)
403
+ with gr.Row().style(equal_height=True):
404
+ btn_clone_flax = gr.Button("Clone Diffusers Flax from 🤗")
405
+ btn_to_pt = gr.Button("Convert to Diffusers PT")
406
+ btn_push_pt = gr.Button("Push Diffusers PT to 🤗")
407
+ btn_delete_pt = gr.Button("Delete Diffusers PT")
408
+ btn_clone_flax.click(clone_flax, inputs=[text_flax_model_from], outputs=out_pt)
409
+ btn_to_pt.click(flax_to_pt, outputs=out_pt)
410
+ btn_push_pt.click(push_pt, inputs=[text_pt_model_to, text_pt_token, text_pt_branch], outputs=out_pt)
411
+ btn_delete_pt.click(delete_pt, outputs=out_pt)
412
+ gr.Markdown(
413
+ """
414
+ ### diffusers pytorch to ckpt
415
+ pt_model_from = prompthero/openjourney <br />
416
+ ckpt_name = openjourney <br />
417
+ ckpt_model_to = camenduru/openjourney <br />
418
+ branch = ckpt <br />
419
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write
420
+ """)
421
+ with gr.Group():
422
+ with gr.Box():
423
+ with gr.Row().style(equal_height=True):
424
+ text_pt_model_from = gr.Textbox(show_label=False, max_lines=1, placeholder="pt_model_from")
425
+ text_ckpt_name = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_name")
426
+ text_ckpt_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_model_to")
427
+ text_ckpt_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="ckpt_branch")
428
+ text_ckpt_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
429
+ out_ckpt = gr.Textbox(show_label=False)
430
+ with gr.Row().style(equal_height=True):
431
+ btn_clone_pt = gr.Button("Clone Diffusers PT from 🤗")
432
+ btn_to_ckpt = gr.Button("Convert to CKPT")
433
+ btn_push_ckpt = gr.Button("Push CKPT to 🤗")
434
+ btn_delete_ckpt = gr.Button("Delete CKPT")
435
+ btn_clone_pt.click(clone_pt, inputs=[text_pt_model_from], outputs=out_ckpt)
436
+ btn_to_ckpt.click(to_ckpt, inputs=[text_ckpt_name], outputs=out_ckpt)
437
+ btn_push_ckpt.click(push_ckpt, inputs=[text_ckpt_model_to, text_ckpt_token, text_ckpt_branch], outputs=out_ckpt)
438
+ btn_delete_ckpt.click(delete_ckpt, outputs=out_ckpt)
439
+ gr.Markdown(
440
+ """
441
+ ### ckpt to safetensors <br />
442
+ ckpt_url = <small>https://huggingface.co/prompthero/openjourney/resolve/main/mdjrny-v4.ckpt or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/5616?type=Model&format=PickleTensor"</small><br />
443
+ safetensors_name = openjourney <br />
444
+ safetensors_model_to = camenduru/openjourney <br />
445
+ branch = safetensors <br />
446
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write <br />
447
+ """)
448
+ with gr.Group():
449
+ with gr.Box():
450
+ with gr.Row().style(equal_height=True):
451
+ text_ckpt_url = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_url")
452
+ text_safetensors_name = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_name")
453
+ text_safetensors_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_model_to")
454
+ text_safetensors_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="safetensors_branch")
455
+ text_safetensors_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
456
+ out_safetensors = gr.Textbox(show_label=False)
457
+ with gr.Row().style(equal_height=True):
458
+ btn_download_ckpt = gr.Button("Download CKPT")
459
+ btn_to_safetensors = gr.Button("Convert to Safetensors")
460
+ btn_push_safetensors = gr.Button("Push Safetensors to 🤗")
461
+ btn_delete_safetensors = gr.Button("Delete Safetensors")
462
+ btn_download_ckpt.click(download_ckpt, inputs=[text_ckpt_url], outputs=out_safetensors)
463
+ btn_to_safetensors.click(to_safetensors, inputs=[text_safetensors_name], outputs=out_safetensors)
464
+ btn_push_safetensors.click(push_safetensors, inputs=[text_safetensors_model_to, text_safetensors_token, text_safetensors_branch], outputs=out_safetensors)
465
+ btn_delete_safetensors.click(delete_safetensors, outputs=out_safetensors)
466
+ gr.Markdown(
467
+ """
468
+ ### safetensors to ckpt <br />
469
+ safetensors_url = <small>https://huggingface.co/prompthero/openjourney/resolve/main/mdjrny-v4.safetensors or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/5616?type=Model&format=SafeTensor"</small><br />
470
+ ckpt_name = openjourney <br />
471
+ ckpt_model_to = camenduru/openjourney <br />
472
+ branch = ckpt <br />
473
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write <br />
474
+ """)
475
+ with gr.Group():
476
+ with gr.Box():
477
+ with gr.Row().style(equal_height=True):
478
+ text_safetensors_url = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_url")
479
+ text_safetensors_to_ckpt_name = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_name")
480
+ text_safetensors_to_ckpt_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_model_to")
481
+ text_safetensors_to_ckpt_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="ckpt_branch")
482
+ text_safetensors_to_ckpt_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
483
+ out_safetensors_to_ckpt = gr.Textbox(show_label=False)
484
+ with gr.Row().style(equal_height=True):
485
+ btn_download_safetensors = gr.Button("Download Safetensors")
486
+ btn_safetensors_to_ckpt = gr.Button("Convert to CKPT")
487
+ btn_push_safetensors_to_ckpt = gr.Button("Push CKPT to 🤗")
488
+ btn_delete_safetensors_ckpt = gr.Button("Delete CKPT")
489
+ btn_download_safetensors.click(download_safetensors, inputs=[text_safetensors_url], outputs=out_safetensors_to_ckpt)
490
+ btn_safetensors_to_ckpt.click(from_safetensors_to_ckpt, inputs=[text_safetensors_to_ckpt_name], outputs=out_safetensors_to_ckpt)
491
+ btn_push_safetensors_to_ckpt.click(push_ckpt, inputs=[text_safetensors_to_ckpt_model_to, text_safetensors_to_ckpt_token, text_safetensors_to_ckpt_branch], outputs=out_safetensors_to_ckpt)
492
+ btn_delete_safetensors_ckpt.click(delete_ckpt, outputs=out_safetensors_to_ckpt)
493
+ gr.Markdown(
494
+ """
495
+ ### safetensors to safetensors emaonly <br />
496
+ safetensors_url = <small>https://huggingface.co/ckpt/anything-v3.0/resolve/main/Anything-V3.0.safetensors or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/4298?type=Model&format=SafeTensor"</small><br />
497
+ emaonly_name = Anything-V3.0 <br />
498
+ emaonly_model_to = camenduru/Anything-V3.0 <br />
499
+ branch = safetensors <br />
500
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write <br />
501
+ """)
502
+ with gr.Group():
503
+ with gr.Box():
504
+ with gr.Row().style(equal_height=True):
505
+ text_safetensors_url = gr.Textbox(show_label=False, max_lines=1, placeholder="safetensors_url")
506
+ text_safetensors_to_emaonly_name = gr.Textbox(show_label=False, max_lines=1, placeholder="emaonly_name")
507
+ text_safetensors_to_emaonly_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="emaonly_model_to")
508
+ text_safetensors_to_emaonly_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="emaonly_branch")
509
+ text_safetensors_to_emaonly_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
510
+ out_safetensors_to_emaonly = gr.Textbox(show_label=False)
511
+ with gr.Row().style(equal_height=True):
512
+ btn_download_safetensors = gr.Button("Download Safetensors")
513
+ btn_safetensors_to_emaonly = gr.Button("Convert to EMA Safetensors")
514
+ btn_push_safetensors_to_emaonly = gr.Button("Push EMA Safetensors to 🤗")
515
+ btn_delete_safetensors_emaonly = gr.Button("Delete EMA Safetensors")
516
+ btn_download_safetensors.click(download_safetensors, inputs=[text_safetensors_url], outputs=out_safetensors_to_emaonly)
517
+ btn_safetensors_to_emaonly.click(from_safetensors_to_emaonly, inputs=[text_safetensors_to_emaonly_name], outputs=out_safetensors_to_emaonly)
518
+ btn_push_safetensors_to_emaonly.click(push_safetensors, inputs=[text_safetensors_to_emaonly_model_to, text_safetensors_to_emaonly_token, text_safetensors_to_emaonly_branch], outputs=out_safetensors_to_emaonly)
519
+ btn_delete_safetensors_emaonly.click(delete_safetensors, outputs=out_safetensors_to_emaonly)
520
+ gr.Markdown(
521
+ """
522
+ ### swap ckpt vae <br />
523
+ ckpt_url = <small>https://huggingface.co/ckpt/anything-v3.0/resolve/main/Anything-V3.0-pruned.ckpt or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/75?type=Model&format=PickleTensor"</small><br />
524
+ vae_url = <small>https://huggingface.co/ckpt/anything-v3.0/resolve/main/Anything-V3.0.vae.pt or https://drive.google.com/file/d/file-id/view?usp=share_link or "https://civitai.com/api/download/models/5809?type=VAE&format=Other"</small><br />
525
+ swaped_ckpt_name = Anything-V3.0 <br />
526
+ swaped_ckpt_model_to = camenduru/Anything-V3.0 <br />
527
+ swaped_ckpt_branch = ckpt <br />
528
+ token = get from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) new token role=write <br />
529
+ """)
530
+ with gr.Group():
531
+ with gr.Box():
532
+ with gr.Row().style(equal_height=True):
533
+ text_ckpt_url = gr.Textbox(show_label=False, max_lines=1, placeholder="ckpt_url")
534
+ text_vae_url = gr.Textbox(show_label=False, max_lines=1, placeholder="vae_url")
535
+ text_swap_ckpt_name = gr.Textbox(show_label=False, max_lines=1, placeholder="swaped_ckpt_name")
536
+ text_swap_ckpt_model_to = gr.Textbox(show_label=False, max_lines=1, placeholder="swaped_ckpt_model_to")
537
+ text_swap_ckpt_branch = gr.Textbox(show_label=False, value="main", max_lines=1, placeholder="swaped_ckpt_branch")
538
+ text_swap_ckpt_token = gr.Textbox(show_label=False, max_lines=1, placeholder="🤗 token")
539
+ out_swap_ckpt = gr.Textbox(show_label=False)
540
+ with gr.Row().style(equal_height=True):
541
+ btn_download_ckpt = gr.Button("Download CKPT")
542
+ btn_download_vae = gr.Button("Download VAE")
543
+ btn_to_swap_ckpt = gr.Button("Swap CKPT VAE")
544
+ btn_push_swap_ckpt = gr.Button("Push CKPT to 🤗")
545
+ btn_delete_swap_ckpt = gr.Button("Delete CKPT")
546
+ btn_download_ckpt.click(download_ckpt, inputs=[text_ckpt_url], outputs=out_swap_ckpt)
547
+ btn_download_vae.click(download_vae, inputs=[text_vae_url], outputs=out_swap_ckpt)
548
+ btn_to_swap_ckpt.click(swap_ckpt_vae, inputs=[text_swap_ckpt_name], outputs=out_swap_ckpt)
549
+ btn_push_swap_ckpt.click(push_ckpt, inputs=[text_swap_ckpt_model_to, text_swap_ckpt_token, text_swap_ckpt_branch], outputs=out_swap_ckpt)
550
+ btn_delete_swap_ckpt.click(delete_ckpt, outputs=out_swap_ckpt)
551
+
552
+ block.launch()
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ aria2
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jax[cpu]==0.4.4
2
+ flax==0.6.6
3
+ diffusers==0.13.1
4
+ accelerate==0.16.0
5
+ transformers==4.26.1
6
+ huggingface-hub==0.11.0
7
+ torch==1.13.1
8
+ safetensors==0.2.8
9
+ gdown==4.6.4
10
+ pytorch_lightning
11
+ ftfy
12
+ OmegaConf