chengzeyi commited on
Commit
34313a1
·
verified ·
1 Parent(s): 2efb1cf

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -399,8 +399,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
399
 
400
  performance_plot = gr.Plot(label="Performance Metrics")
401
 
402
- with gr.Accordion("Recent Generations (last 32)", open=False):
403
- recent_gallery = gr.Gallery(label="Prompt and Output", columns=3, rows=1, show_label=True)
 
 
 
 
 
 
404
 
405
  def update_recent_gallery(prompt, results):
406
  recent_generations.append({
@@ -409,13 +415,20 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
409
  "hidream-dev": results["hidream-dev"],
410
  "hidream-full": results["hidream-full"],
411
  })
412
- if len(recent_generations) > 32:
413
  recent_generations.pop(0)
414
- gallery_items = [
415
- (r["prompt"], r["flux-dev"], r["hidream-dev"], r["hidream-full"])
416
- for r in reversed(recent_generations)
417
- ]
418
- return gr.update(value=gallery_items)
 
 
 
 
 
 
 
419
 
420
  # Add custom CSS for the big status box
421
  css = """
 
399
 
400
  performance_plot = gr.Plot(label="Performance Metrics")
401
 
402
+ with gr.Accordion("Recent Generations (last 8)", open=False):
403
+ recent_gallery = gr.Gallery(
404
+ label="Recent Generations",
405
+ show_label=False,
406
+ elem_id="recent-gallery",
407
+ columns=4,
408
+ height="auto",
409
+ ).style(grid=2)
410
 
411
  def update_recent_gallery(prompt, results):
412
  recent_generations.append({
 
415
  "hidream-dev": results["hidream-dev"],
416
  "hidream-full": results["hidream-full"],
417
  })
418
+ if len(recent_generations) > 8:
419
  recent_generations.pop(0)
420
+
421
+ # Flatten the images from each generation
422
+ all_images = []
423
+ for gen in reversed(recent_generations): # Show newest first
424
+ all_images.extend([
425
+ gen["flux-dev"],
426
+ gen["hidream-dev"],
427
+ gen["hidream-full"]
428
+ ])
429
+
430
+ # Update the Gradio gallery with the new list
431
+ return recent_gallery.update(value=all_images)
432
 
433
  # Add custom CSS for the big status box
434
  css = """