ciover2024 commited on
Commit
0bf2ba9
1 Parent(s): 8b0b992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -79,7 +79,8 @@ def encode_image(orig_image):
79
  img_str = base64.b64encode(buffered.getvalue())
80
  return img_str
81
 
82
- def resize_image(orig_image):
 
83
  aspect_ratio = orig_image.height / orig_image.width
84
  old_width = orig_image.width
85
  new_width = int(orig_image.width*1.2)
@@ -171,7 +172,7 @@ def generate_image_old(image_path, mask_path, text_prompt="undress", negative_pr
171
  "ImagePrompt", # str in 'Type' Radio component
172
 
173
  fn_index=33
174
- )
175
 
176
 
177
  def generate_image(image_path, mask_path, text_prompt="undress", negative_prompt=""):
@@ -213,7 +214,7 @@ def generate_image(image_path, mask_path, text_prompt="undress", negative_prompt
213
  "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
214
  ["Left"], # List[str] in 'Outpaint Direction' Checkboxgroup component
215
  "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
216
- "Howdy!", # str in 'Inpaint Additional Prompt' Textbox component
217
  "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Mask Upload' Image component
218
  True, # bool in 'Disable Preview' Checkbox component
219
  True, # bool in 'Disable Intermediate Results' Checkbox component
@@ -387,7 +388,7 @@ def process_image(input_image):
387
  # Open the mask image and perform inpainting
388
  mask_image = Image.open(mask_image_path)
389
 
390
- result_image = resize_image(mask_image)
391
 
392
  # Clean up temporary files
393
  os.remove(input_image_path)
 
79
  img_str = base64.b64encode(buffered.getvalue())
80
  return img_str
81
 
82
+ def resize_image(input_image, mask_image):
83
+ orig_image = mask_image.resize(input_image.size, Image.BICUBIC)
84
  aspect_ratio = orig_image.height / orig_image.width
85
  old_width = orig_image.width
86
  new_width = int(orig_image.width*1.2)
 
172
  "ImagePrompt", # str in 'Type' Radio component
173
 
174
  fn_index=33
175
+ )
176
 
177
 
178
  def generate_image(image_path, mask_path, text_prompt="undress", negative_prompt=""):
 
214
  "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
215
  ["Left"], # List[str] in 'Outpaint Direction' Checkboxgroup component
216
  "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
217
+ "", # str in 'Inpaint Additional Prompt' Textbox component
218
  "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Mask Upload' Image component
219
  True, # bool in 'Disable Preview' Checkbox component
220
  True, # bool in 'Disable Intermediate Results' Checkbox component
 
388
  # Open the mask image and perform inpainting
389
  mask_image = Image.open(mask_image_path)
390
 
391
+ result_image = resize_image(input_image, mask_image)
392
 
393
  # Clean up temporary files
394
  os.remove(input_image_path)