tonyassi commited on
Commit
9539987
1 Parent(s): cfe97ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -5,7 +5,15 @@ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype
5
  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")
6
 
7
  def generate(image_editor):
8
- return image_editor
 
 
 
 
 
 
 
 
9
 
10
  with gr.Blocks() as demo:
11
  gr.Markdown("""
@@ -31,6 +39,6 @@ with gr.Blocks() as demo:
31
  out2 = gr.Image()
32
  out3 = gr.Image()
33
 
34
- generate_button.click(fn=generate, inputs=sketch_pad, outputs=sketch_pad)
35
 
36
  demo.launch()
 
5
  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")
6
 
7
  def generate(image_editor):
8
+ image = image_editor['background'].convert('RGB')
9
+ mask = Image.new("RGBA", image_editor["layers"][0].size, "WHITE")
10
+ mask.paste(image_editor["layers"][0], (0, 0), image_editor["layers"][0])
11
+ mask = ImageOps.invert(mask.convert('L'))
12
+
13
+ image.thumbnail((1024, 1024))
14
+ mask.thumbnail((1024, 1024))
15
+
16
+ return image_editor, image, mask
17
 
18
  with gr.Blocks() as demo:
19
  gr.Markdown("""
 
39
  out2 = gr.Image()
40
  out3 = gr.Image()
41
 
42
+ generate_button.click(fn=generate, inputs=sketch_pad, outputs=[sketch_pad, out1, out2])
43
 
44
  demo.launch()