Update app.py
Browse files
app.py
CHANGED
@@ -67,10 +67,13 @@ def extract_image(img, pos_prompts, neg_prompts, threshold, alpha_value=0.5):
|
|
67 |
output_image[:, :, :3] = img_np[:, :, :3]
|
68 |
output_image[:, :, 3] = (final_mask * alpha_value * 255).astype(np.uint8)
|
69 |
|
70 |
-
# convert the output_image back to
|
71 |
output_image = Image.fromarray(output_image, "RGBA")
|
|
|
|
|
|
|
|
|
72 |
|
73 |
-
return output_image, final_mask.astype(np.uint8), bmask
|
74 |
|
75 |
|
76 |
|
|
|
67 |
output_image[:, :, :3] = img_np[:, :, :3]
|
68 |
output_image[:, :, 3] = (final_mask * alpha_value * 255).astype(np.uint8)
|
69 |
|
70 |
+
# convert the output_image, final_mask, and bmask back to PIL.Image objects
|
71 |
output_image = Image.fromarray(output_image, "RGBA")
|
72 |
+
final_mask = Image.fromarray((final_mask * 255).astype(np.uint8), "L")
|
73 |
+
bmask = Image.fromarray((bmask * 255).astype(np.uint8), "L")
|
74 |
+
|
75 |
+
return output_image, final_mask, bmask
|
76 |
|
|
|
77 |
|
78 |
|
79 |
|