Manjushri commited on
Commit
50d6bd5
1 Parent(s): 07bc541

Update app.py

Browse files

Added Iterations Slider

Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -17,16 +17,16 @@ def resize(height,img):
17
  img = img.resize((wsize,baseheight), Image.Resampling.LANCZOS)
18
  return img
19
 
20
- def predict(source_img, prompt, negative_prompt):
21
  imageio.imwrite("data.png", source_img["image"])
22
  imageio.imwrite("data_mask.png", source_img["mask"])
23
  src = resize(512, "data.png")
24
  src.save("src.png")
25
  mask = resize(512, "data_mask.png")
26
  mask.save("mask.png")
27
- image = pipe(prompt=prompt, negative_prompt=negative_prompt, image=src, mask_image=mask, num_inference_steps=10).images[0]
28
  return image
29
 
30
  title="Stable Diffusion 2.0 Inpainting CPU"
31
  description="Inpainting with Stable Diffusion 2.0 <br />Warning: Slow process... ~10 min inference time.<br> <b>Please use 512x512 or 768x768 square .png image as input to avoid memory error!!!</b>"
32
- gr.Interface(fn=predict, inputs=[gr.Image(source="upload", type="numpy", tool="sketch", elem_id="source_container"), gr.Textbox(label='What you want the AI to Generate, 77 Token limit'), gr.Textbox(label='What you Do Not want the AI to generate')], outputs='image', title=title, description=description, article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(max_threads=True, debug=True)
 
17
  img = img.resize((wsize,baseheight), Image.Resampling.LANCZOS)
18
  return img
19
 
20
+ def predict(source_img, prompt, negative_prompt, steps):
21
  imageio.imwrite("data.png", source_img["image"])
22
  imageio.imwrite("data_mask.png", source_img["mask"])
23
  src = resize(512, "data.png")
24
  src.save("src.png")
25
  mask = resize(512, "data_mask.png")
26
  mask.save("mask.png")
27
+ image = pipe(prompt=prompt, negative_prompt=negative_prompt, image=src, mask_image=mask, num_inference_steps=steps).images[0]
28
  return image
29
 
30
  title="Stable Diffusion 2.0 Inpainting CPU"
31
  description="Inpainting with Stable Diffusion 2.0 <br />Warning: Slow process... ~10 min inference time.<br> <b>Please use 512x512 or 768x768 square .png image as input to avoid memory error!!!</b>"
32
+ gr.Interface(fn=predict, inputs=[gr.Image(source="upload", type="numpy", tool="sketch", elem_id="source_container"), gr.Textbox(label='What you want the AI to Generate, 77 Token limit'), gr.Textbox(label='What you Do Not want the AI to generate'), gr.Slider(5, 25, 10, step=1, label='Number of Iterations')], outputs='image', title=title, description=description, article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(max_threads=True, debug=True)