praeclarumjj3 commited on
Commit
5e41805
1 Parent(s): bd11a0f
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -77,8 +77,9 @@ def inpaint(input_img, mask, option):
77
  else:
78
  mask = mask.resize((width,height))
79
 
80
- input_img = input_img.resize(512, 512)
81
- mask = mask.resize(512, 512)
 
82
 
83
  mask = mask.convert('L')
84
  mask = np.array(mask) / 255.
@@ -95,12 +96,12 @@ def inpaint(input_img, mask, option):
95
  rgb_erased = rgb_erased * (1 - mask_tensor) # erase rgb
96
  rgb_erased = rgb_erased.to(torch.float32)
97
 
98
- # model = create_model("models/places_512.pkl")
99
- # comp_img = fcf_inpaint(G=model, org_img=rgb.to(torch.float32), erased_img=rgb_erased.to(torch.float32), mask=mask_tensor.to(torch.float32))
100
  rgb_erased = denorm(rgb_erased)
101
- # comp_img = denorm(comp_img)
102
 
103
- return show_images(rgb_erased), show_images(rgb_erased)
104
 
105
  gradio_inputs = [gr.inputs.Image(type='pil',
106
  tool=None,
 
77
  else:
78
  mask = mask.resize((width,height))
79
 
80
+ if width is not 512 or height is not 512:
81
+ input_img = input_img.resize((512, 512))
82
+ mask = mask.resize((512, 512))
83
 
84
  mask = mask.convert('L')
85
  mask = np.array(mask) / 255.
 
96
  rgb_erased = rgb_erased * (1 - mask_tensor) # erase rgb
97
  rgb_erased = rgb_erased.to(torch.float32)
98
 
99
+ model = create_model("models/places_512.pkl")
100
+ comp_img = fcf_inpaint(G=model, org_img=rgb.to(torch.float32), erased_img=rgb_erased.to(torch.float32), mask=mask_tensor.to(torch.float32))
101
  rgb_erased = denorm(rgb_erased)
102
+ comp_img = denorm(comp_img)
103
 
104
+ return show_images(rgb_erased), show_images(comp_img)
105
 
106
  gradio_inputs = [gr.inputs.Image(type='pil',
107
  tool=None,