Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|