yizhangliu commited on
Commit
46bf436
1 Parent(s): 43859c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -104,7 +104,7 @@ def preprocess_mask(mask):
104
  mask = torch.from_numpy(mask)
105
  return mask
106
 
107
- def load_img(nparr, gray: bool = False):
108
  # alpha_channel = None
109
  # nparr = np.frombuffer(img_bytes, np.uint8)
110
  if gray:
@@ -131,7 +131,8 @@ def model_process(image, mask):
131
  image_pil = Image.fromarray(image)
132
  mask_pil = Image.fromarray(mask).convert("L")
133
  print(f'image_pil_ = {image_pil.shape}')
134
- print(f'mask_pil_ = {mask_pil.shape}')
 
135
 
136
  image, alpha_channel = load_img(image)
137
  # Origin image shape: (512, 512, 3)
@@ -185,9 +186,8 @@ def model_process(image, mask):
185
  # logger.info(f"Resized image shape: {image.shape}")
186
  print(f"Resized image shape: {image.shape} / {image[250][250]}")
187
 
188
- #mask, _ = load_img(input["mask"].read(), gray=True)
189
- mask_pil.save(f'./mask_pil.png')
190
- mask = np.array(mask_pil)
191
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
192
  print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]}")
193
 
 
104
  mask = torch.from_numpy(mask)
105
  return mask
106
 
107
+ def load_img(nparr, gray: bool = False):
108
  # alpha_channel = None
109
  # nparr = np.frombuffer(img_bytes, np.uint8)
110
  if gray:
 
131
  image_pil = Image.fromarray(image)
132
  mask_pil = Image.fromarray(mask).convert("L")
133
  print(f'image_pil_ = {image_pil.shape}')
134
+ print(f'mask_pil_ = {mask_pil.shape}')
135
+ mask_pil.save(f'./mask_pil.png')
136
 
137
  image, alpha_channel = load_img(image)
138
  # Origin image shape: (512, 512, 3)
 
186
  # logger.info(f"Resized image shape: {image.shape}")
187
  print(f"Resized image shape: {image.shape} / {image[250][250]}")
188
 
189
+ mask, _ = load_img(mask), gray=True)
190
+ # mask = np.array(mask_pil)
 
191
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
192
  print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]}")
193