KingYuuki commited on
Commit
3e1f937
1 Parent(s): 3f3674a

Upload 6 files

Browse files
animefull-final-pruned/config.yaml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 1.0e-04
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.00085
6
+ linear_end: 0.0120
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: "jpg"
11
+ cond_stage_key: "txt"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false # Note: different from the one we trained before
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+
20
+ scheduler_config: # 10000 warmup steps
21
+ target: ldm.lr_scheduler.LambdaLinearScheduler
22
+ params:
23
+ warm_up_steps: [ 10000 ]
24
+ cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases
25
+ f_start: [ 1.e-6 ]
26
+ f_max: [ 1. ]
27
+ f_min: [ 1. ]
28
+
29
+ unet_config:
30
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
31
+ params:
32
+ image_size: 32 # unused
33
+ in_channels: 4
34
+ out_channels: 4
35
+ model_channels: 320
36
+ attention_resolutions: [ 4, 2, 1 ]
37
+ num_res_blocks: 2
38
+ channel_mult: [ 1, 2, 4, 4 ]
39
+ num_heads: 8
40
+ use_spatial_transformer: True
41
+ transformer_depth: 1
42
+ context_dim: 768
43
+ use_checkpoint: True
44
+ legacy: False
45
+
46
+ first_stage_config:
47
+ target: ldm.models.autoencoder.AutoencoderKL
48
+ params:
49
+ embed_dim: 4
50
+ monitor: val/rec_loss
51
+ ddconfig:
52
+ double_z: true
53
+ z_channels: 4
54
+ resolution: 512
55
+ in_channels: 3
56
+ out_ch: 3
57
+ ch: 128
58
+ ch_mult:
59
+ - 1
60
+ - 2
61
+ - 4
62
+ - 4
63
+ num_res_blocks: 2
64
+ attn_resolutions: []
65
+ dropout: 0.0
66
+ lossconfig:
67
+ target: torch.nn.Identity
68
+
69
+ cond_stage_config:
70
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
animefull-final-pruned/model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89d59c3dde4c56c6d5c41da34cc55ce479d93b4007046980934b14db71bdb2a8
3
+ size 4265377440
sd-prune/anime700k-64bs-0.1ucg-penultimate-1epoch-clip-ema-continue-76000-ema-pruned.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:939269be42067dc822b206b2fada2947a5c20e896059036705b56d68236bd7ef
3
+ size 2132882528
sd-prune/anime700k-64bs-0.1ucg-penultimate-1epoch-clip-ema-continue-76000.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:828a21b769b3a32b1508f3b47828fc9d7c27c14a0cab64bc42fb785cd24211a6
3
+ size 7703828146
sd-prune/prune.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+
4
+
5
+ def prune_it(p, keep_only_ema=True):
6
+ print(f"prunin' in path: {p}")
7
+ size_initial = os.path.getsize(p)
8
+ nsd = dict()
9
+ sd = torch.load(p, map_location="cpu")
10
+ print(sd.keys())
11
+ #for k in sd.keys():
12
+ # if k != "optimizer_states":
13
+ # nsd[k] = sd[k]
14
+ #else:
15
+ # print(f"removing optimizer states for path {p}")
16
+ if "global_step" in sd:
17
+ print(f"This is global step {sd['global_step']}.")
18
+ if keep_only_ema:
19
+ if "state_dict" in sd:
20
+ sd = sd["state_dict"]
21
+ # infer ema keys
22
+ ema_keys = {k: "model_ema." + k[6:].replace(".", ".") for k in sd.keys() if k.startswith("model.")}
23
+ new_sd = {"state_dict": {}}
24
+
25
+ for k in sd:
26
+ ema_k = "___"
27
+ try:
28
+ ema_k = "model_ema." + k[6:].replace(".", "")
29
+ except:
30
+ pass
31
+ if ema_k in sd:
32
+ new_sd[k] = sd[ema_k]#.half()
33
+ print("ema: " + ema_k + " > " + k)
34
+ elif not k.startswith("model_ema.") or k in ["model_ema.num_updates", "model_ema.decay"]:
35
+ new_sd[k] = sd[k]#.half()
36
+ print(k)
37
+ else:
38
+ print("skipped: " + k)
39
+ if k in new_sd and isinstance(new_sd[k], torch.FloatTensor):
40
+ new_sd[k] = new_sd[k]#.half()
41
+
42
+ #assert len(new_sd) == len(sd) - len(ema_keys)
43
+ nsd["state_dict"] = new_sd
44
+ else:
45
+ sd = nsd['state_dict'].copy()
46
+ new_sd = dict()
47
+ for k in sd:
48
+ new_sd[k] = sd[k]#.half()
49
+ nsd['state_dict'] = new_sd
50
+
51
+ fn = f"{os.path.splitext(p)[0]}-pruned.ckpt" if not keep_only_ema else f"{os.path.splitext(p)[0]}-ema-pruned.ckpt"
52
+ print(f"saving pruned checkpoint at: {fn}")
53
+ torch.save(nsd, fn)
54
+ newsize = os.path.getsize(fn)
55
+ MSG = f"New ckpt size: {newsize*1e-9:.2f} GB. " + \
56
+ f"Saved {(size_initial - newsize)*1e-9:.2f} GB by removing optimizer states"
57
+ if keep_only_ema:
58
+ MSG += " and non-EMA weights"
59
+ print(MSG)
60
+
61
+
62
+ if __name__ == "__main__":
63
+ #prune_it('anime700k-64bs-0.1ucg-penultimate-1epoch-clip-ema-continue-76000.pt')
64
+ import sys
65
+ prune_it(sys.argv[1])
vector_adjust/v2.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac22b73b16510d16b8480a1a0d6c487556eac7eda0b6c9436ba862d8f22139ca
3
+ size 2953951