Add Image Gallery of generated images(of current session)

#12
by zenafey - opened
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -162,7 +162,7 @@ for model_name in model_list:
162
  name_without_ext = remove_id_and_ext(model_name)
163
  model_names[name_without_ext] = model_name
164
 
165
- def flip_text(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
166
  result = prodia_client.generate({
167
  "prompt": prompt,
168
  "negative_prompt": negative_prompt,
@@ -177,7 +177,10 @@ def flip_text(prompt, negative_prompt, model, steps, sampler, cfg_scale, width,
177
 
178
  job = prodia_client.wait(result)
179
 
180
- return job["imageUrl"]
 
 
 
181
 
182
 
183
  css = """
@@ -250,8 +253,6 @@ with gr.Blocks(css=css) as demo:
250
 
251
  with gr.Column(scale=2):
252
  image_output = gr.Image(value="https://images.prodia.xyz/8ede1a7c-c0ee-4ded-987d-6ffed35fc477.png")
253
-
254
- text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed], outputs=image_output)
255
 
256
  with gr.Tab("PNG Info"):
257
  def plaintext_to_html(text, classname=None):
@@ -285,9 +286,13 @@ with gr.Blocks(css=css) as demo:
285
  with gr.Column():
286
  exif_output = gr.HTML(label="EXIF Data")
287
  send_to_txt2img_btn = gr.Button("Send to txt2img")
288
-
289
- image_input.upload(get_exif_data, inputs=[image_input], outputs=exif_output)
290
- send_to_txt2img_btn.click(send_to_txt2img, inputs=[image_input], outputs=[tabs, prompt, negative_prompt, steps, seed,
 
 
 
 
291
  model, sampler, width, height, cfg_scale])
292
 
293
  demo.queue(concurrency_count=32)
 
162
  name_without_ext = remove_id_and_ext(model_name)
163
  model_names[name_without_ext] = model_name
164
 
165
+ def flip_text(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed, gallery):
166
  result = prodia_client.generate({
167
  "prompt": prompt,
168
  "negative_prompt": negative_prompt,
 
177
 
178
  job = prodia_client.wait(result)
179
 
180
+ new_images_list = [img['name'] for img in gallery]
181
+ new_images_list.insert(0, job["imageUrl"])
182
+
183
+ return {image_output: job["imageUrl"], gallery_obj: new_images_list}
184
 
185
 
186
  css = """
 
253
 
254
  with gr.Column(scale=2):
255
  image_output = gr.Image(value="https://images.prodia.xyz/8ede1a7c-c0ee-4ded-987d-6ffed35fc477.png")
 
 
256
 
257
  with gr.Tab("PNG Info"):
258
  def plaintext_to_html(text, classname=None):
 
286
  with gr.Column():
287
  exif_output = gr.HTML(label="EXIF Data")
288
  send_to_txt2img_btn = gr.Button("Send to txt2img")
289
+
290
+ with gr.Tab("Gallery"):
291
+ gallery_obj = gr.Gallery(height=500, columns=4)
292
+
293
+ text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed, gallery_obj], outputs=[image_output, gallery_obj])
294
+ image_input.upload(get_exif_data, inputs=[image_input], outputs=exif_output)
295
+ send_to_txt2img_btn.click(send_to_txt2img, inputs=[image_input], outputs=[tabs, prompt, negative_prompt, steps, seed,
296
  model, sampler, width, height, cfg_scale])
297
 
298
  demo.queue(concurrency_count=32)