Hpsoyl commited on
Commit
1834127
·
1 Parent(s): f432ef9
Files changed (2) hide show
  1. app.py +10 -9
  2. models/pipeline_ddpm_text_encoder.py +2 -1
app.py CHANGED
@@ -406,7 +406,7 @@ def get_gallery_selection(evt: gr.SelectData):
406
 
407
  # --- Generation Functions ---
408
  @spaces.GPU(duration=120)
409
- def generate_t2i(prompt, num_inference_steps, num_images, current_color, height, width):
410
  """
411
  Generates multiple images for Text-to-Image and returns a gallery.
412
  """
@@ -659,9 +659,9 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
659
  t2i_steps = gr.Slider(10, 200, 50, step=1, label="Inference Steps")
660
  # Added: Number of Images Slider
661
  t2i_num_images = gr.Slider(1, 9, 3, step=1, label="Number of Images")
662
- with gr.Row():
663
- t2i_height = gr.Slider(256, 4096, value=512, step=64, label="Height")
664
- t2i_width = gr.Slider(256, 4096, value=512, step=64, label="Width")
665
  t2i_btn = gr.Button("Generate", variant="primary")
666
  with gr.Column(scale=2):
667
  # Changed: Image to Gallery
@@ -675,11 +675,12 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
675
  t2i_dl = gr.DownloadButton(label="Download All (.zip)")
676
  t2i_gal = gr.Gallery(value=t2i_examples, label="Examples", columns=6, height="auto")
677
 
678
- t2i_btn.click(
679
- generate_t2i,
680
- inputs=[t2i_prompt, t2i_steps, t2i_num_images, t2i_color, t2i_height, t2i_width],
681
- outputs=[t2i_gallery_out, t2i_dl, t2i_raw_state, t2i_colorbar]
682
- )
 
683
  # Reuse update_gallery_color since state is now a list
684
  t2i_color.change(update_gallery_color, [t2i_raw_state, t2i_color], [t2i_gallery_out, t2i_colorbar])
685
  t2i_gal.select(fn=get_gallery_selection, inputs=None, outputs=t2i_prompt)
 
406
 
407
  # --- Generation Functions ---
408
  @spaces.GPU(duration=120)
409
+ def generate_t2i(prompt, num_inference_steps, num_images, current_color, height=512, width=512):
410
  """
411
  Generates multiple images for Text-to-Image and returns a gallery.
412
  """
 
659
  t2i_steps = gr.Slider(10, 200, 50, step=1, label="Inference Steps")
660
  # Added: Number of Images Slider
661
  t2i_num_images = gr.Slider(1, 9, 3, step=1, label="Number of Images")
662
+ # with gr.Row():
663
+ # t2i_height = gr.Slider(512, 1024, value=512, step=64, label="Height")
664
+ # t2i_width = gr.Slider(512, 1024, value=512, step=64, label="Width")
665
  t2i_btn = gr.Button("Generate", variant="primary")
666
  with gr.Column(scale=2):
667
  # Changed: Image to Gallery
 
675
  t2i_dl = gr.DownloadButton(label="Download All (.zip)")
676
  t2i_gal = gr.Gallery(value=t2i_examples, label="Examples", columns=6, height="auto")
677
 
678
+ t2i_btn.click(generate_t2i, [t2i_prompt, t2i_steps, t2i_num_images, t2i_color], [t2i_gallery_out, t2i_dl, t2i_raw_state, t2i_colorbar])
679
+ # t2i_btn.click(
680
+ # generate_t2i,
681
+ # inputs=[t2i_prompt, t2i_steps, t2i_num_images, t2i_color, t2i_height, t2i_width],
682
+ # outputs=[t2i_gallery_out, t2i_dl, t2i_raw_state, t2i_colorbar]
683
+ # )
684
  # Reuse update_gallery_color since state is now a list
685
  t2i_color.change(update_gallery_color, [t2i_raw_state, t2i_color], [t2i_gallery_out, t2i_colorbar])
686
  t2i_gal.select(fn=get_gallery_selection, inputs=None, outputs=t2i_prompt)
models/pipeline_ddpm_text_encoder.py CHANGED
@@ -164,4 +164,5 @@ class DDPMPipeline(DiffusionPipeline):
164
  if not return_dict:
165
  return (image,)
166
 
167
- return ImagePipelineOutput(images=image)
 
 
164
  if not return_dict:
165
  return (image,)
166
 
167
+ return ImagePipelineOutput(images=image)
168
+