Maxixa commited on
Commit
aded561
1 Parent(s): e2a2ff5

Upload with huggingface_hub

Browse files
UnstableDream-fp16-pruned.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bfd01675c0e524139118b1a984379f0c6e61f4edb29c127544731706a56028fb
3
+ size 2132625431
cafe-insta-fp16-pruned.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90c38a0b0f5d845663dfc1c72090192a2e6844d09c7090a9e43422d2f2489176
3
+ size 2132625431
dreamshaper-fp16-pruned.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4741f8ceb9f38f01d1778bb036e79e4b98a97fdbd364277f297f294e1bc4824
3
+ size 2132654231
f22-fp16-pruned.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a35508599c80e98c1f56bd9c2543e62ac44abbf805a99f2097a9304fef937182
3
+ size 2132866262
hassanFantasi-fp16-pruned.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2acb1fa7221344b74c5375a6fb5279a53ad3cc25b39adc180dc13b923742ac6
3
+ size 2132625431
prune.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2022 Lopho <contact@lopho.org>
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Affero General Public License as published
5
+ # by the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Affero General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Affero General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+
17
+ def prune(
18
+ checkpoint,
19
+ fp16 = False,
20
+ ema = False,
21
+ clip = True,
22
+ vae = True,
23
+ depth = True,
24
+ unet = True,
25
+ ):
26
+ sd = checkpoint
27
+ nested_sd = False
28
+ if 'state_dict' in sd:
29
+ sd = sd['state_dict']
30
+ nested_sd = True
31
+ sd_pruned = dict()
32
+ for k in sd:
33
+ cp = unet and k.startswith('model.diffusion_model.')
34
+ cp = cp or (depth and k.startswith('depth_model.'))
35
+ cp = cp or (vae and k.startswith('first_stage_model.'))
36
+ cp = cp or (clip and k.startswith('cond_stage_model.'))
37
+ if cp:
38
+ k_in = k
39
+ if ema:
40
+ k_ema = 'model_ema.' + k[6:].replace('.', '')
41
+ if k_ema in sd:
42
+ k_in = k_ema
43
+ sd_pruned[k] = sd[k_in].half() if fp16 else sd[k_in]
44
+ if nested_sd:
45
+ return { 'state_dict': sd_pruned }
46
+ else:
47
+ return sd_pruned
48
+
49
+ def main(args):
50
+ import os
51
+ from argparse import ArgumentParser
52
+ from functools import partial
53
+ parser = ArgumentParser(
54
+ description = "Prune a stable diffusion checkpoint",
55
+ epilog = "Copyright (C) 2022 Lopho <contact@lopho.org> | \
56
+ Licensed under the AGPLv3 <https://www.gnu.org/licenses/>"
57
+ )
58
+ parser.add_argument(
59
+ 'input',
60
+ type = str,
61
+ help = "input checkpoint"
62
+ )
63
+ parser.add_argument(
64
+ 'output',
65
+ type = str,
66
+ help = "output checkpoint"
67
+ )
68
+ parser.add_argument(
69
+ '-p', '--fp16',
70
+ action = 'store_true',
71
+ help = "convert to float16"
72
+ )
73
+ parser.add_argument(
74
+ '-e', '--ema',
75
+ action = 'store_true',
76
+ help = "use EMA for weights"
77
+ )
78
+ parser.add_argument(
79
+ '-c', '--no-clip',
80
+ action = 'store_true',
81
+ help = "strip CLIP weights"
82
+ )
83
+ parser.add_argument(
84
+ '-a', '--no-vae',
85
+ action = 'store_true',
86
+ help = "strip VAE weights"
87
+ )
88
+ parser.add_argument(
89
+ '-d', '--no-depth',
90
+ action = 'store_true',
91
+ help = "strip depth model weights"
92
+ )
93
+ parser.add_argument(
94
+ '-u', '--no-unet',
95
+ action = 'store_true',
96
+ help = "strip UNet weights"
97
+ )
98
+ def error(self, message):
99
+ import sys
100
+ sys.stderr.write(f"error: {message}\n")
101
+ self.print_help()
102
+ self.exit()
103
+ parser.error = partial(error, parser) # type: ignore
104
+ args = parser.parse_args(args)
105
+ is_safetensors = os.path.splitext(args.input)[1].lower() == '.safetensors'
106
+ if is_safetensors:
107
+ from safetensors.torch import load_file, save_file
108
+ input_sd = load_file(args.input)
109
+ else:
110
+ from torch import load, save
111
+ import pickle as python_pickle
112
+ class torch_pickle:
113
+ class Unpickler(python_pickle.Unpickler):
114
+ def find_class(self, module, name):
115
+ try:
116
+ return super().find_class(module, name)
117
+ except:
118
+ return None
119
+ input_sd = load(args.input, pickle_module = torch_pickle) # type: ignore
120
+ pruned = prune(
121
+ input_sd,
122
+ fp16 = args.fp16,
123
+ ema = args.ema,
124
+ clip = not args.no_clip,
125
+ vae = not args.no_vae,
126
+ depth = not args.no_depth,
127
+ unet = not args.no_unet
128
+ )
129
+ if is_safetensors:
130
+ save_file(pruned, args.output)
131
+ else:
132
+ save(pruned, args.output)
133
+
134
+
135
+ if __name__ == '__main__':
136
+ import sys
137
+ main(sys.argv[1:])
138
+
sigmaMergeAdv2-fp16-pruned.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33d255c97486692a35f875a8ab9f0f30c9a8848d61ea2f9e31de95d9dc2adf5a
3
+ size 2132878789