File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ def __init__(
62
62
dtype = dtype ,
63
63
device = device
64
64
)
65
- self .is_8b = True
65
+ self .is_8b = False
66
66
67
67
def forward (
68
68
self ,
Original file line number Diff line number Diff line change @@ -375,14 +375,17 @@ def do_sampling(
375
375
self .print ("Sampling done" )
376
376
return latent
377
377
378
- def vae_encode (self , image , controlnet_cond : bool = False ) -> torch .Tensor :
378
+ def vae_encode (self , image , using_2b_controlnet : bool = False ) -> torch .Tensor :
379
379
self .print ("Encoding image to latent..." )
380
380
image = image .convert ("RGB" )
381
381
image_np = np .array (image ).astype (np .float32 ) / 255.0
382
382
image_np = np .moveaxis (image_np , 2 , 0 )
383
383
batch_images = np .expand_dims (image_np , axis = 0 ).repeat (1 , axis = 0 )
384
384
image_torch = torch .from_numpy (batch_images ).cuda ()
385
- image_torch = 2.0 * image_torch - 1.0
385
+ if using_2b_controlnet :
386
+ image_torch = image_torch * 255
387
+ else :
388
+ image_torch = 2.0 * image_torch - 1.0
386
389
image_torch = image_torch .cuda ()
387
390
self .vae .model = self .vae .model .cuda ()
388
391
latent = self .vae .model .encode (image_torch ).cpu ()
You can’t perform that action at this time.
0 commit comments