cocktailpeanut commited on
Commit
ac5a6b4
1 Parent(s): e6d7547
Files changed (1) hide show
  1. app.py +30 -12
app.py CHANGED
@@ -1609,7 +1609,7 @@ if __name__ == "__main__":
1609
  parser.add_argument('--resolution', default='1024,1024', help="target resolution")
1610
  parser.add_argument('--use_multidiffusion', default=False, action='store_true', help="use multidiffusion or not")
1611
  parser.add_argument('--use_guassian', default=False, action='store_true', help="use guassian or not")
1612
- parser.add_argument('--use_dilated_sampling', default=False, action='store_true', help="use dilated sampling or not")
1613
  parser.add_argument('--use_progressive_upscaling', default=False, action='store_true', help="use progressive upscaling or not")
1614
  parser.add_argument('--shuffle', default=False, action='store_true', help="shuffle or not")
1615
  parser.add_argument('--use_skip_residual', default=False, action='store_true', help="use skip_residual or not")
@@ -1634,7 +1634,8 @@ if __name__ == "__main__":
1634
  # GRADIO MODE
1635
 
1636
  # @spaces.GPU()
1637
- def infer(prompt, resolution, num_inference_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
 
1638
  set_seed(seed)
1639
  width,height = list(map(int, resolution.split(',')))
1640
  cross_attention_kwargs = {"edit_type": "visualize",
@@ -1667,17 +1668,24 @@ if __name__ == "__main__":
1667
  sigma=args.sigma, use_guassian=args.use_guassian,
1668
  multi_decoder=args.multi_decoder,
1669
  upscale_mode=args.upscale_mode,
1670
- use_multidiffusion=args.use_multidiffusion,
1671
- use_skip_residual=args.use_skip_residual,
1672
- use_progressive_upscaling=args.use_progressive_upscaling,
1673
- use_dilated_sampling=args.use_dilated_sampling,
1674
- shuffle=args.shuffle,
 
 
 
 
 
1675
  result_path=result_path,
1676
- debug=args.debug, save_attention_map=args.save_attention_map, use_md_prompt=args.use_md_prompt, c=args.c
 
1677
  )
1678
  print(images)
1679
 
1680
- return images[0]
 
1681
 
1682
  css = """
1683
  #col-container{
@@ -1728,14 +1736,23 @@ if __name__ == "__main__":
1728
  choices = [
1729
  "1024,1024", "2048,2048", "2048,1024", "1536,3072", "3072,3072", "4096,4096", "4096,2048"
1730
  ],
1731
- value = "1024,1024"
 
 
1732
  )
1733
  with gr.Column():
1734
  num_inference_steps = gr.Slider(label="Inference Steps", minimum=2, maximum=50, step=1, value=50)
1735
  guidance_scale = gr.Slider(label="Guidance Scale", minimum=1, maximum=510, step=0.1, value=7.5)
1736
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
 
 
 
 
 
 
1737
 
1738
- output_images = gr.Image(label="Output Image", format="png")
 
1739
  gr.Examples(
1740
  examples = [
1741
  ["Astronaut on Mars during sunset."],
@@ -1746,7 +1763,8 @@ if __name__ == "__main__":
1746
  )
1747
  submit_btn.click(
1748
  fn = infer,
1749
- inputs = [prompt, resolution, num_inference_steps, guidance_scale, seed],
 
1750
  outputs = [output_images],
1751
  show_api=False
1752
  )
 
1609
  parser.add_argument('--resolution', default='1024,1024', help="target resolution")
1610
  parser.add_argument('--use_multidiffusion', default=False, action='store_true', help="use multidiffusion or not")
1611
  parser.add_argument('--use_guassian', default=False, action='store_true', help="use guassian or not")
1612
+ parser.add_argument('--use_dilated_sampling', default=True, action='store_true', help="use dilated sampling or not")
1613
  parser.add_argument('--use_progressive_upscaling', default=False, action='store_true', help="use progressive upscaling or not")
1614
  parser.add_argument('--shuffle', default=False, action='store_true', help="shuffle or not")
1615
  parser.add_argument('--use_skip_residual', default=False, action='store_true', help="use skip_residual or not")
 
1634
  # GRADIO MODE
1635
 
1636
  # @spaces.GPU()
1637
+ def infer(prompt, resolution, num_inference_steps, guidance_scale, seed, use_multidiffusion, use_skip_residual, use_dilated_sampling, use_progressive_upscaling, shuffle, use_md_prompt, progress=gr.Progress(track_tqdm=True)):
1638
+ #def infer(prompt, resolution, num_inference_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
1639
  set_seed(seed)
1640
  width,height = list(map(int, resolution.split(',')))
1641
  cross_attention_kwargs = {"edit_type": "visualize",
 
1668
  sigma=args.sigma, use_guassian=args.use_guassian,
1669
  multi_decoder=args.multi_decoder,
1670
  upscale_mode=args.upscale_mode,
1671
+ use_multidiffusion=use_multidiffusion,
1672
+ use_skip_residual=use_skip_residual,
1673
+ use_progressive_upscaling=use_progressive_upscaling,
1674
+ use_dilated_sampling=use_dilated_sampling,
1675
+ shuffle=shuffle,
1676
+ #use_multidiffusion=args.use_multidiffusion,
1677
+ #use_skip_residual=args.use_skip_residual,
1678
+ #use_progressive_upscaling=args.use_progressive_upscaling,
1679
+ #use_dilated_sampling=args.use_dilated_sampling,
1680
+ #shuffle=args.shuffle,
1681
  result_path=result_path,
1682
+ #debug=args.debug, save_attention_map=args.save_attention_map, use_md_prompt=args.use_md_prompt, c=args.c
1683
+ debug=args.debug, save_attention_map=args.save_attention_map, use_md_prompt=use_md_prompt, c=args.c
1684
  )
1685
  print(images)
1686
 
1687
+ #return images[0]
1688
+ return images
1689
 
1690
  css = """
1691
  #col-container{
 
1736
  choices = [
1737
  "1024,1024", "2048,2048", "2048,1024", "1536,3072", "3072,3072", "4096,4096", "4096,2048"
1738
  ],
1739
+ #value = "1024,1024"
1740
+ value = "2048,2048",
1741
+ interactive=False
1742
  )
1743
  with gr.Column():
1744
  num_inference_steps = gr.Slider(label="Inference Steps", minimum=2, maximum=50, step=1, value=50)
1745
  guidance_scale = gr.Slider(label="Guidance Scale", minimum=1, maximum=510, step=0.1, value=7.5)
1746
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
1747
+ use_multidiffusion = gr.Checkbox(label="use_multidiffusion", value=True)
1748
+ use_skip_residual = gr.Checkbox(label="use_skip_residual", value=True)
1749
+ use_dilated_sampling = gr.Checkbox(label="use_dilated_sampling", value=True)
1750
+ use_progressive_upscaling = gr.Checkbox(label="use_progressive_upscaling", value=False)
1751
+ shuffle = gr.Checkbox(label="shuffle", value=False)
1752
+ use_md_prompt = gr.Checkbox(label="use_md_prompt", value=False)
1753
 
1754
+ # output_images = gr.Image(label="Output Image", format="png")
1755
+ output_images = gr.Gallery(label="Output Image", format="png")
1756
  gr.Examples(
1757
  examples = [
1758
  ["Astronaut on Mars during sunset."],
 
1763
  )
1764
  submit_btn.click(
1765
  fn = infer,
1766
+ #inputs = [prompt, resolution, num_inference_steps, guidance_scale, seed],
1767
+ inputs = [prompt, resolution, num_inference_steps, guidance_scale, seed, use_multidiffusion, use_skip_residual, use_dilated_sampling, use_progressive_upscaling, shuffle, use_md_prompt],
1768
  outputs = [output_images],
1769
  show_api=False
1770
  )