gokaygokay commited on
Commit
63c257d
·
verified ·
1 Parent(s): dbdec24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -16,8 +16,12 @@ def process_image(input_image, torchscript_jit, output_type):
16
  if output_type == "Mask only":
17
  # Process the image and get only the mask
18
  output = remover.process(input_image, type='map')
19
- # Convert the mask to a black and white image
20
- mask = Image.fromarray((output * 255).astype(np.uint8))
 
 
 
 
21
  return mask
22
  else:
23
  # Process the image and return the RGBA result
 
16
  if output_type == "Mask only":
17
  # Process the image and get only the mask
18
  output = remover.process(input_image, type='map')
19
+ if isinstance(output, Image.Image):
20
+ # If output is already a PIL Image, convert to grayscale
21
+ mask = output.convert('L')
22
+ else:
23
+ # If output is a numpy array, convert to PIL Image
24
+ mask = Image.fromarray((output * 255).astype(np.uint8), mode='L')
25
  return mask
26
  else:
27
  # Process the image and return the RGBA result