lllyasviel commited on
Commit
ebfe47d
·
1 Parent(s): 6070c4a
Files changed (1) hide show
  1. entry.py +19 -3
entry.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import math
3
  import numpy as np
4
  import torch
 
5
  import safetensors.torch
6
 
7
  from omegaconf import OmegaConf
@@ -91,9 +92,7 @@ config_path = './sd_xl_base.yaml'
91
  config = OmegaConf.load(config_path)
92
  model = instantiate_from_config(config.model).cpu()
93
  model.eval()
94
-
95
- sd = safetensors.torch.load_file('./sd_xl_base_1.0.safetensors')
96
- model.load_state_dict(sd, strict=False)
97
 
98
  model.conditioner.cuda()
99
 
@@ -114,4 +113,21 @@ c, uc = model.conditioner.get_unconditional_conditioning(
114
  batch_uc=batch_uc)
115
  model.conditioner.cpu()
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  a = 0
 
2
  import math
3
  import numpy as np
4
  import torch
5
+ import gc
6
  import safetensors.torch
7
 
8
  from omegaconf import OmegaConf
 
92
  config = OmegaConf.load(config_path)
93
  model = instantiate_from_config(config.model).cpu()
94
  model.eval()
95
+ model.load_state_dict(safetensors.torch.load_file('./sd_xl_base_1.0.safetensors'), strict=False)
 
 
96
 
97
  model.conditioner.cuda()
98
 
 
113
  batch_uc=batch_uc)
114
  model.conditioner.cpu()
115
 
116
+ torch.cuda.empty_cache()
117
+ torch.cuda.ipc_collect()
118
+
119
+ shape = (1, 4, 128, 128)
120
+ randn = torch.randn(shape).cuda()
121
+
122
+
123
+ def denoiser(input, sigma, c):
124
+ return model.denoiser(model.model, input, sigma, c)
125
+
126
+
127
+ model.model.cuda()
128
+ model.denoiser.cuda()
129
+ samples_z = sampler(denoiser, randn, cond=c, uc=uc)
130
+ model.model.cpu()
131
+ model.denoiser.cpu()
132
+
133
  a = 0