Manjushri commited on
Commit
fae4bf4
1 Parent(s): 413c1cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -15,7 +15,7 @@ def resize(value,img):
15
  img = img.resize((value,value))
16
  return img
17
 
18
- def predict(source_img, prompt, strength):
19
  imageio.imwrite("data.png", source_img['image'])
20
  imageio.imwrite("data_mask.png", source_img["mask"])
21
  src = resize(768, "data.png")
@@ -24,10 +24,14 @@ def predict(source_img, prompt, strength):
24
  mask.save("mask.png")
25
  image = pipe(prompt=prompt, image=src, mask_image=mask, num_inference_steps=6, strength=strength, guidance_scale=0.0).images[0]
26
  return image
27
-
 
 
 
 
28
  title="SDXL Turbo Inpainting CPU"
29
  description="Inpainting with SDXL Turbo <br><br> <b>Please use square .png image as input, 512x512, 768x768, or 1024x1024</b>"
30
- gr.Interface(fn=predict, inputs=[gr.Image(source=("upload"), tool='sketch', label='Source Image'),
31
  gr.Textbox(label='What you want the AI to Generate, 77 Token limit'),
32
  gr.Slider(minimum=.5, maximum=1, value=.75, step=.025, label='Strength')],
33
  outputs='image',
 
15
  img = img.resize((value,value))
16
  return img
17
 
18
+ def img2img(source_img, prompt, strength):
19
  imageio.imwrite("data.png", source_img['image'])
20
  imageio.imwrite("data_mask.png", source_img["mask"])
21
  src = resize(768, "data.png")
 
24
  mask.save("mask.png")
25
  image = pipe(prompt=prompt, image=src, mask_image=mask, num_inference_steps=6, strength=strength, guidance_scale=0.0).images[0]
26
  return image
27
+
28
+ def txt2img(prompt):
29
+ image=pipe(prompt=prompt, num_inference_steps=3, guidance_scale=0.0).images[0]
30
+ return image
31
+
32
  title="SDXL Turbo Inpainting CPU"
33
  description="Inpainting with SDXL Turbo <br><br> <b>Please use square .png image as input, 512x512, 768x768, or 1024x1024</b>"
34
+ gr.Interface(fn=[img2img, txt2img], inputs=[gr.Image(source=("upload"), tool='sketch', label='Source Image'),
35
  gr.Textbox(label='What you want the AI to Generate, 77 Token limit'),
36
  gr.Slider(minimum=.5, maximum=1, value=.75, step=.025, label='Strength')],
37
  outputs='image',