yizhangliu commited on
Commit
4aefcfd
·
1 Parent(s): 383d7cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -234,6 +234,8 @@ def model_process_filepath(input): #image, mask):
234
  print(f'origin_image_bytes = ', type(origin_image_bytes), len(origin_image_bytes))
235
 
236
  image, alpha_channel = load_img(origin_image_bytes)
 
 
237
  original_shape = image.shape
238
  interpolation = cv2.INTER_CUBIC
239
 
@@ -284,7 +286,7 @@ def model_process_filepath(input): #image, mask):
284
  logger.info(f"Resized image shape: {image.shape} / {type(image)}")
285
  print(f"Resized image shape: {image.shape} / {image[250][250]}")
286
 
287
- mask, alpha_channel = load_img(read_content(input["mask"]), gray=True)
288
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
289
  print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]} / {alpha_channel}")
290
 
@@ -310,7 +312,8 @@ def model_process_filepath(input): #image, mask):
310
  (res_np_img, alpha_channel[:, :, np.newaxis]), axis=-1
311
  )
312
  print(f"liuyz_here_40_: {alpha_channel.shape} / {res_np_img.shape} / {alpha_channel.dtype} / {res_np_img.dtype}")
313
- print(f"process time_2_: {(time.time() - start) * 1000}ms, {alpha_channel.shape}, {res_np_img.shape} / {res_np_img[250][250]} / {res_np_img.dtype}")
 
314
 
315
  image = Image.fromarray(res_np_img)
316
  image.save(f'./result_image.png')
 
234
  print(f'origin_image_bytes = ', type(origin_image_bytes), len(origin_image_bytes))
235
 
236
  image, alpha_channel = load_img(origin_image_bytes)
237
+
238
+ alpha_channel = (np.ones((image.shape[0],image.shape[1]))*255).astype(np.uint8)
239
  original_shape = image.shape
240
  interpolation = cv2.INTER_CUBIC
241
 
 
286
  logger.info(f"Resized image shape: {image.shape} / {type(image)}")
287
  print(f"Resized image shape: {image.shape} / {image[250][250]}")
288
 
289
+ mask, _ = load_img(read_content(input["mask"]), gray=True)
290
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
291
  print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]} / {alpha_channel}")
292
 
 
312
  (res_np_img, alpha_channel[:, :, np.newaxis]), axis=-1
313
  )
314
  print(f"liuyz_here_40_: {alpha_channel.shape} / {res_np_img.shape} / {alpha_channel.dtype} / {res_np_img.dtype}")
315
+ ext = get_image_ext(origin_image_bytes)
316
+ print(f"process time_2_: {(time.time() - start) * 1000}ms, {alpha_channel.shape}, {res_np_img.shape} / {res_np_img[250][250]} / {res_np_img.dtype} /{ext}")
317
 
318
  image = Image.fromarray(res_np_img)
319
  image.save(f'./result_image.png')