Lawrence-cj commited on
Commit
eaa59c1
1 Parent(s): accee48
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -143,16 +143,11 @@ if torch.cuda.is_available():
143
  print("Model Compiled!")
144
 
145
 
146
- def save_image(img, seed=''):
147
- unique_name = f"{str(uuid.uuid4())}_{seed}.png"
148
- save_path = os.path.join(f'output/online_demo_img/{datetime.now().date()}')
149
- os.umask(0o000) # file permission: 666; dir permission: 777
150
- os.makedirs(save_path, exist_ok=True)
151
- unique_name = os.path.join(save_path, unique_name)
152
  img.save(unique_name)
153
  return unique_name
154
 
155
-
156
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
157
  if randomize_seed:
158
  seed = random.randint(0, MAX_SEED)
@@ -182,8 +177,6 @@ def generate(
182
  ):
183
  seed = int(randomize_seed_fn(seed, randomize_seed))
184
  generator = torch.Generator().manual_seed(seed)
185
- print(f"{PORT}: {model_path}")
186
- print(prompt)
187
 
188
  if schedule == 'DPM-Solver':
189
  if not isinstance(pipe.scheduler, DPMSolverMultistepScheduler):
@@ -213,10 +206,10 @@ def generate(
213
  num_images_per_prompt=num_imgs,
214
  use_resolution_binning=use_resolution_binning,
215
  output_type="pil",
216
- max_sequence_length=args.T5_token_max_length,
217
  ).images
218
 
219
- image_paths = [save_image(img, seed) for img in images]
220
  print(image_paths)
221
  return image_paths, seed
222
 
 
143
  print("Model Compiled!")
144
 
145
 
146
+ def save_image(img):
147
+ unique_name = str(uuid.uuid4()) + ".png"
 
 
 
 
148
  img.save(unique_name)
149
  return unique_name
150
 
 
151
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
152
  if randomize_seed:
153
  seed = random.randint(0, MAX_SEED)
 
177
  ):
178
  seed = int(randomize_seed_fn(seed, randomize_seed))
179
  generator = torch.Generator().manual_seed(seed)
 
 
180
 
181
  if schedule == 'DPM-Solver':
182
  if not isinstance(pipe.scheduler, DPMSolverMultistepScheduler):
 
206
  num_images_per_prompt=num_imgs,
207
  use_resolution_binning=use_resolution_binning,
208
  output_type="pil",
209
+ max_sequence_length=T5_token_max_length,
210
  ).images
211
 
212
+ image_paths = [save_image(img) for img in images]
213
  print(image_paths)
214
  return image_paths, seed
215