Androidonnxfork
commited on
Commit
•
aaf8596
1
Parent(s):
1ce5dbc
Upload folder using huggingface_hub
Browse files- android.py +51 -0
- cyberreal.tar.gz +3 -0
- cyberrealistic.ckpt +3 -0
- deliberate.ckpt +3 -0
- deliberate.tar.gz +3 -0
- realisticv5.ckpt +3 -0
- realisticv5.tar.gz +3 -0
android.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Helper script to convert diffusion checkpoints to format used by image generator."""
|
2 |
+
|
3 |
+
import os
|
4 |
+
|
5 |
+
from absl import app
|
6 |
+
from absl import flags
|
7 |
+
import requests
|
8 |
+
import torch as th
|
9 |
+
|
10 |
+
|
11 |
+
_CKPT_PATH = flags.DEFINE_string(
|
12 |
+
"ckpt_path", default=None, help="Path to checkpoint file", required=True)
|
13 |
+
_OUTPUT_PATH = flags.DEFINE_string(
|
14 |
+
"output_path", default="bins", help="Output folder path", required=False)
|
15 |
+
|
16 |
+
VOCAB_URL = "https://openaipublic.blob.core.windows.net/clip/bpe_simple_vocab_16e6.txt"
|
17 |
+
|
18 |
+
|
19 |
+
def run(ckpt_path, output_path):
|
20 |
+
"""Converts the checkpoint and saves the result.
|
21 |
+
|
22 |
+
Args:
|
23 |
+
ckpt_path: Source checkpoint path
|
24 |
+
output_path: Result folder directory
|
25 |
+
"""
|
26 |
+
os.makedirs(output_path, exist_ok=True)
|
27 |
+
ckpt = th.load(ckpt_path, map_location="cpu")
|
28 |
+
|
29 |
+
vocab_dest = os.path.join(output_path, os.path.basename(VOCAB_URL))
|
30 |
+
if not os.path.exists(vocab_dest):
|
31 |
+
with requests.get(VOCAB_URL, stream=True) as response:
|
32 |
+
with open(vocab_dest, "wb") as vocab_file:
|
33 |
+
for c in response.iter_content(chunk_size=8192):
|
34 |
+
vocab_file.write(c)
|
35 |
+
|
36 |
+
for k, v in ckpt["state_dict"].items():
|
37 |
+
if "first_stage_model.encoder" in k:
|
38 |
+
continue
|
39 |
+
if not hasattr(v, "numpy"):
|
40 |
+
continue
|
41 |
+
output_bin_file = os.path.join(output_path, f"{k}.bin")
|
42 |
+
v.numpy().astype("float16").tofile(output_bin_file)
|
43 |
+
|
44 |
+
|
45 |
+
def main(_) -> None:
|
46 |
+
ckpt_path = _CKPT_PATH.value
|
47 |
+
output_path = _OUTPUT_PATH.value
|
48 |
+
run(ckpt_path, output_path)
|
49 |
+
|
50 |
+
if __name__ == "__main__":
|
51 |
+
app.run(main)
|
cyberreal.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:82f4b986e57c60adca973bb343c3624f2746c613b840746e29ea6950f0d986db
|
3 |
+
size 1904506478
|
cyberrealistic.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:847246342f97a238d1f14a2fc9e84d0a3f79242c4327ed4b2d8da420cfbb00b6
|
3 |
+
size 4265336233
|
deliberate.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:04a3d94264470e88d6c5307c3ff6d7d05f588b8c5c8049c82545b8e4be023303
|
3 |
+
size 4265339632
|
deliberate.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85cea451eec057fa7e734548ca3ba6d779ed5836a3f9de14b8394575ef0d7d8e
|
3 |
+
size 45
|
realisticv5.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1f8103bf8336747984b86c52b8d6fe836206cdc0534be8c036f422161a418f38
|
3 |
+
size 4265346494
|
realisticv5.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e3e664351a3b6ae0d26a24bd66688c1efca10a361211842d093f81115f8f7ec7
|
3 |
+
size 1906287236
|