RageshAntony commited on
Commit
91d9deb
·
verified ·
1 Parent(s): e1c259b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -44
app.py CHANGED
@@ -269,49 +269,49 @@ css = """
269
 
270
 
271
 
272
- @spaces.GPU(duration=400)
273
- def generate_all(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
274
- progress=gr.Progress()):
275
- outputs = [None] * (len(MODEL_CONFIGS) * 2)
276
- for idx, model_name in enumerate(MODEL_CONFIGS.keys()):
277
- try:
278
- # Display progress for the specific model
279
- # progress(0, desc=f"Starting generation for {model_name}...")
280
- print(f"IMAGE GENERATING {model_name} ")
281
- image, used_seed = generate_image(
282
- model_name, prompt, negative_prompt, seed,
283
- randomize_seed, width, height, guidance_scale,
284
- num_inference_steps, progress
285
- )
286
- print(f"IMAGE GENERATIED {model_name} ")
287
- # Update the respective model's tab with the generated image
288
- # results[model_name].update(image)
289
- # seeds[model_name].update(used_seed)
290
- outputs[idx * 2] = image # Image slot
291
- outputs[idx * 2 + 1] = seed # Seed slot
292
- # outputs.extend([image, used_seed])
293
- # Add intermediate results to progress * (len(all_outputs) - len(all_outputs))
294
- print("YELID")
295
- yield outputs + [None]
296
-
297
-
298
- except Exception as e:
299
- print(f"Error generating with {model_name}: {str(e)}")
300
- outputs[idx * 2] = None
301
- outputs[idx * 2 + 1] = None
302
-
303
- # Update the gallery after generation
304
- gallery_images = update_gallery()
305
- # file_gallery.update(value=gallery_images)
306
- return outputs
307
-
308
- def update_gallery():
309
- """Update the file gallery"""
310
- files = get_generated_images()
311
- return [
312
- (f["path"], f"{f['name']}\n{f['date']}")
313
- for f in files
314
- ]
315
 
316
  with gr.Blocks(css=css) as demo:
317
  with gr.Column(elem_id="col-container"):
@@ -397,7 +397,7 @@ with gr.Blocks(css=css) as demo:
397
  height=800,
398
  visible=True
399
  )
400
- refresh_button = gr.Button("Refresh Gallery",visible=True)
401
 
402
  refresh_button.click(
403
  fn=update_gallery,
 
269
 
270
 
271
 
272
+ @spaces.GPU(duration=400)
273
+ def generate_all(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
274
+ progress=gr.Progress()):
275
+ outputs = [None] * (len(MODEL_CONFIGS) * 2)
276
+ for idx, model_name in enumerate(MODEL_CONFIGS.keys()):
277
+ try:
278
+ # Display progress for the specific model
279
+ # progress(0, desc=f"Starting generation for {model_name}...")
280
+ print(f"IMAGE GENERATING {model_name} {prompt}")
281
+ image, used_seed = generate_image(
282
+ model_name, prompt, negative_prompt, seed,
283
+ randomize_seed, width, height, guidance_scale,
284
+ num_inference_steps, progress
285
+ )
286
+ print(f"IMAGE GENERATIED {model_name} ")
287
+ # Update the respective model's tab with the generated image
288
+ # results[model_name].update(image)
289
+ # seeds[model_name].update(used_seed)
290
+ outputs[idx * 2] = image # Image slot
291
+ outputs[idx * 2 + 1] = seed # Seed slot
292
+ # outputs.extend([image, used_seed])
293
+ # Add intermediate results to progress * (len(all_outputs) - len(all_outputs))
294
+ print("YELID")
295
+ yield outputs + [None]
296
+
297
+
298
+ except Exception as e:
299
+ print(f"Error generating with {model_name}: {str(e)}")
300
+ outputs[idx * 2] = None
301
+ outputs[idx * 2 + 1] = None
302
+
303
+ # Update the gallery after generation
304
+ gallery_images = update_gallery()
305
+ # file_gallery.update(value=gallery_images)
306
+ return outputs
307
+
308
+ def update_gallery():
309
+ """Update the file gallery"""
310
+ files = get_generated_images()
311
+ return [
312
+ (f["path"], f"{f['name']}\n{f['date']}")
313
+ for f in files
314
+ ]
315
 
316
  with gr.Blocks(css=css) as demo:
317
  with gr.Column(elem_id="col-container"):
 
397
  height=800,
398
  visible=True
399
  )
400
+ refresh_button = gr.Button("Refresh Gallery",visible=True) # not visible. why?
401
 
402
  refresh_button.click(
403
  fn=update_gallery,