6
6
7
7
import torch
8
8
from PIL import Image
9
- from ldm .invoke .devices import choose_autocast
10
- from ldm .invoke .image_util import InitImageResizer
11
9
12
10
from ldm .invoke .generator .base import Generator
13
11
from ldm .invoke .generator .omnibus import Omnibus
@@ -47,13 +45,16 @@ def make_image(x_T):
47
45
ddim_num_steps = steps , ddim_eta = ddim_eta , verbose = False
48
46
)
49
47
48
+ #x = self.get_noise(init_width, init_height)
49
+ x = x_T
50
+
50
51
if self .free_gpu_mem and self .model .model .device != self .model .device :
51
52
self .model .model .to (self .model .device )
52
53
53
54
samples , _ = sampler .sample (
54
55
batch_size = 1 ,
55
56
S = steps ,
56
- x_T = x_T ,
57
+ x_T = x ,
57
58
conditioning = c ,
58
59
shape = shape ,
59
60
verbose = False ,
@@ -69,21 +70,11 @@ def make_image(x_T):
69
70
)
70
71
71
72
# resizing
72
-
73
- image = self .sample_to_image (samples )
74
- image = InitImageResizer (image ).resize (width , height )
75
-
76
- image = np .array (image ).astype (np .float32 ) / 255.0
77
- image = image [None ].transpose (0 , 3 , 1 , 2 )
78
- image = torch .from_numpy (image )
79
- image = 2.0 * image - 1.0
80
- image = image .to (self .model .device )
81
-
82
- scope = choose_autocast (self .precision )
83
- with scope (self .model .device .type ):
84
- samples = self .model .get_first_stage_encoding (
85
- self .model .encode_first_stage (image )
86
- ) # move back to latent space
73
+ samples = torch .nn .functional .interpolate (
74
+ samples ,
75
+ size = (height // self .downsampling_factor , width // self .downsampling_factor ),
76
+ mode = "bilinear"
77
+ )
87
78
88
79
t_enc = int (strength * steps )
89
80
ddim_sampler = DDIMSampler (self .model , device = self .model .device )
0 commit comments