Leyo HF staff commited on
Commit
9b576ce
1 Parent(s): 983bd2f

simplify template gallery

Browse files
Files changed (1) hide show
  1. app_dialogue.py +16 -11
app_dialogue.py CHANGED
@@ -75,7 +75,12 @@ PROCESSOR = AutoProcessor.from_pretrained(
75
  )
76
 
77
  BOT_AVATAR = "IDEFICS_logo.png"
78
-
 
 
 
 
 
79
  logging.basicConfig(level=logging.INFO)
80
  logger = logging.getLogger()
81
 
@@ -729,7 +734,7 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
729
  info="Choose the type of gallery you want to see.",
730
  )
731
  template_gallery = gr.Gallery(
732
- # value= value given by gallery_type_choice,
733
  label="Templates Gallery",
734
  allow_preview=False,
735
  columns=6,
@@ -917,12 +922,12 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
917
  queue=False,
918
  )
919
 
920
- gallery_type_choice.change(
921
- fn=choose_gallery,
922
- inputs=[gallery_type_choice],
923
- outputs=[template_gallery],
924
- queue=False,
925
- )
926
  template_gallery.select(
927
  fn=add_file_gallery,
928
  inputs=[template_gallery],
@@ -930,9 +935,9 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
930
  queue=False,
931
  )
932
  demo.load(
933
- fn=choose_gallery,
934
- inputs=[gallery_type_choice],
935
- outputs=[template_gallery],
936
  queue=False,
937
  )
938
  demo.queue(max_size=40, api_open=False)
 
75
  )
76
 
77
  BOT_AVATAR = "IDEFICS_logo.png"
78
+ IMAGE_GALLERY_PATHS = [
79
+ f"example_images/{image_dir}/{ex_image}"
80
+ for image_dir in os.listdir("example_images")
81
+ for ex_image in os.listdir(f"example_images/{image_dir}")
82
+ ]
83
+ random.shuffle(IMAGE_GALLERY_PATHS)
84
  logging.basicConfig(level=logging.INFO)
85
  logger = logging.getLogger()
86
 
 
734
  info="Choose the type of gallery you want to see.",
735
  )
736
  template_gallery = gr.Gallery(
737
+ value=IMAGE_GALLERY_PATHS,
738
  label="Templates Gallery",
739
  allow_preview=False,
740
  columns=6,
 
922
  queue=False,
923
  )
924
 
925
+ # gallery_type_choice.change(
926
+ # fn=choose_gallery,
927
+ # inputs=[gallery_type_choice],
928
+ # outputs=[template_gallery],
929
+ # queue=False,
930
+ # )
931
  template_gallery.select(
932
  fn=add_file_gallery,
933
  inputs=[template_gallery],
 
935
  queue=False,
936
  )
937
  demo.load(
938
+ # fn=choose_gallery,
939
+ # inputs=[gallery_type_choice],
940
+ # outputs=[template_gallery],
941
  queue=False,
942
  )
943
  demo.queue(max_size=40, api_open=False)