tonyassi commited on
Commit
bc11c81
1 Parent(s): 642c2d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -6,6 +6,9 @@ from PIL import Image, ImageOps
6
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
7
  pipeline = AutoPipelineForInpainting.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", vae=vae, torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to("cuda")
8
 
 
 
 
9
  def squarify_image(img):
10
  if(img.height > img.width): bg_size = img.height
11
  else: bg_size = img.width
@@ -76,13 +79,15 @@ with gr.Blocks() as demo:
76
  with gr.Column():
77
  version_gallery = gr.Gallery(label="Versions", type="pil", object_fit='contain')
78
  restore_button = gr.Button("Restore Version")
 
79
 
80
 
81
  with gr.Row():
82
  out1 = gr.Image(format='png')
83
  out2 = gr.Image(format='png')
84
  out3 = gr.Image(format='png')
85
-
 
86
  generate_button.click(fn=generate, inputs=[sketch_pad,prompt, neg_prompt, version_gallery], outputs=[sketch_pad, out1, out2, out3, version_gallery])
87
 
88
  demo.launch()
 
6
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
7
  pipeline = AutoPipelineForInpainting.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", vae=vae, torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to("cuda")
8
 
9
+ def get_select_index(evt: gr.SelectData):
10
+ return evt.index
11
+
12
  def squarify_image(img):
13
  if(img.height > img.width): bg_size = img.height
14
  else: bg_size = img.width
 
79
  with gr.Column():
80
  version_gallery = gr.Gallery(label="Versions", type="pil", object_fit='contain')
81
  restore_button = gr.Button("Restore Version")
82
+ selected = gr.Number(show_label=False, visible=True)
83
 
84
 
85
  with gr.Row():
86
  out1 = gr.Image(format='png')
87
  out2 = gr.Image(format='png')
88
  out3 = gr.Image(format='png')
89
+
90
+ version_gallery.select(get_select_index, None, selected)
91
  generate_button.click(fn=generate, inputs=[sketch_pad,prompt, neg_prompt, version_gallery], outputs=[sketch_pad, out1, out2, out3, version_gallery])
92
 
93
  demo.launch()