ironjr commited on
Commit
d688ce4
·
verified ·
1 Parent(s): fb0409a

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +10 -3
model.py CHANGED
@@ -28,6 +28,7 @@ import torch.nn.functional as F
28
  import torchvision.transforms as T
29
  from einops import rearrange
30
 
 
31
  from collections import deque
32
  from typing import Tuple, List, Literal, Optional, Union
33
  from PIL import Image
@@ -54,6 +55,7 @@ class StreamMultiDiffusion(nn.Module):
54
  delta: float = 1.0,
55
  cfg_type: Literal['none', 'full', 'self', 'initialize'] = 'none',
56
  seed: int = 2024,
 
57
  autoflush: bool = True,
58
  default_mask_std: float = 8.0,
59
  default_mask_strength: float = 1.0,
@@ -71,6 +73,7 @@ class StreamMultiDiffusion(nn.Module):
71
  self.device = device
72
  self.dtype = dtype
73
  self.seed = seed
 
74
  self.sd_version = sd_version
75
 
76
  self.autoflush = autoflush
@@ -1255,12 +1258,16 @@ class StreamMultiDiffusion(nn.Module):
1255
  if not ignore_check_ready and not self.check_ready():
1256
  return
1257
  if not ignore_check_ready and self.is_dirty:
1258
- print("I'm so dirty now!")
1259
  self.commit()
1260
  self.flush()
1261
 
1262
- latent = torch.randn((1, self.unet.config.in_channels, self.latent_height, self.latent_width),
1263
- dtype=self.dtype, device=self.device) # (1, 4, h, w)
 
 
 
 
1264
  latent = torch.cat((latent, self.x_t_latent_buffer), dim=0) # (t, 4, h, w)
1265
  self.stock_noise = torch.cat((self.init_noise[:1], self.stock_noise[:-1]), dim=0) # (t, 4, h, w)
1266
  if self.cfg_type in ('self', 'initialize'):
 
28
  import torchvision.transforms as T
29
  from einops import rearrange
30
 
31
+ import random
32
  from collections import deque
33
  from typing import Tuple, List, Literal, Optional, Union
34
  from PIL import Image
 
55
  delta: float = 1.0,
56
  cfg_type: Literal['none', 'full', 'self', 'initialize'] = 'none',
57
  seed: int = 2024,
58
+ seedfix: bool = False,
59
  autoflush: bool = True,
60
  default_mask_std: float = 8.0,
61
  default_mask_strength: float = 1.0,
 
73
  self.device = device
74
  self.dtype = dtype
75
  self.seed = seed
76
+ self.seedfix = seedfix
77
  self.sd_version = sd_version
78
 
79
  self.autoflush = autoflush
 
1258
  if not ignore_check_ready and not self.check_ready():
1259
  return
1260
  if not ignore_check_ready and self.is_dirty:
1261
+ print("I'm dirty!")
1262
  self.commit()
1263
  self.flush()
1264
 
1265
+ if self.seedfix:
1266
+ self.reset_seed(self.generator, self.seed)
1267
+ latent = self.init_noise[:1]
1268
+ else:
1269
+ latent = torch.randn((1, self.unet.config.in_channels, self.latent_height, self.latent_width),
1270
+ dtype=self.dtype, device=self.device) # (1, 4, h, w)
1271
  latent = torch.cat((latent, self.x_t_latent_buffer), dim=0) # (t, 4, h, w)
1272
  self.stock_noise = torch.cat((self.init_noise[:1], self.stock_noise[:-1]), dim=0) # (t, 4, h, w)
1273
  if self.cfg_type in ('self', 'initialize'):