yizhangliu commited on
Commit
35d654a
1 Parent(s): 22e2ed0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -167,7 +167,9 @@ def model_process(image, mask):
167
  print(f"Resized image shape: {image.shape} / {image[250][250]}")
168
 
169
  #mask, _ = load_img(input["mask"].read(), gray=True)
170
- mask = np.array(Image.fromarray(mask).convert("L"))
 
 
171
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
172
  print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]}")
173
 
@@ -180,8 +182,9 @@ def model_process(image, mask):
180
  print(f"process time: {(time.time() - start) * 1000}ms, {res_np_img.shape} / {res_np_img[250][250]}")
181
 
182
  torch.cuda.empty_cache()
183
-
184
- return Image.fromarray(res_np_img)
 
185
  '''
186
  if alpha_channel is not None:
187
  if alpha_channel.shape[:2] != res_np_img.shape[:2]:
 
167
  print(f"Resized image shape: {image.shape} / {image[250][250]}")
168
 
169
  #mask, _ = load_img(input["mask"].read(), gray=True)
170
+ mask_image = Image.fromarray(mask).convert("L")
171
+ mask_image.save(f'./mask_image.png')
172
+ mask = np.array(mask_image)
173
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
174
  print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]}")
175
 
 
182
  print(f"process time: {(time.time() - start) * 1000}ms, {res_np_img.shape} / {res_np_img[250][250]}")
183
 
184
  torch.cuda.empty_cache()
185
+ image = Image.fromarray(res_np_img)
186
+ image.save(f'./result_image.png')
187
+ return image
188
  '''
189
  if alpha_channel is not None:
190
  if alpha_channel.shape[:2] != res_np_img.shape[:2]: