aredden commited on
Commit
7cec457
·
1 Parent(s): ffa6ff7

Add case where seed is string & try/catch if invalid

Browse files
Files changed (1) hide show
  1. flux_pipeline.py +8 -0
flux_pipeline.py CHANGED
@@ -158,6 +158,14 @@ class FluxPipeline:
158
  if isinstance(seed, (int, float)):
159
  seed = int(abs(seed)) % MAX_RAND
160
  self.rng = torch.manual_seed(seed)
 
 
 
 
 
 
 
 
161
  else:
162
  seed = abs(self.rng.seed()) % MAX_RAND
163
  torch.cuda.manual_seed_all(seed)
 
158
  if isinstance(seed, (int, float)):
159
  seed = int(abs(seed)) % MAX_RAND
160
  self.rng = torch.manual_seed(seed)
161
+ elif isinstance(seed, str):
162
+ try:
163
+ seed = abs(int(seed)) % MAX_RAND
164
+ except Exception as e:
165
+ logger.warning(
166
+ f"Recieved string representation of seed, but was not able to convert to int: {seed}, using random seed"
167
+ )
168
+ seed = abs(self.rng.seed()) % MAX_RAND
169
  else:
170
  seed = abs(self.rng.seed()) % MAX_RAND
171
  torch.cuda.manual_seed_all(seed)