Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,10 @@ def process_image(image, prompt, threshold, alpha_value, draw_rectangles):
|
|
25 |
|
26 |
pred = torch.sigmoid(preds)
|
27 |
mat = pred.cpu().numpy()
|
|
|
|
|
|
|
|
|
28 |
mask = Image.fromarray(np.uint8(mat * 255), "L")
|
29 |
mask = mask.convert("RGB")
|
30 |
mask = mask.resize(image.size)
|
|
|
25 |
|
26 |
pred = torch.sigmoid(preds)
|
27 |
mat = pred.cpu().numpy()
|
28 |
+
|
29 |
+
# Squeeze to remove dimensions of size 1 (batch and channel dimensions)
|
30 |
+
mat = np.squeeze(mat, axis=(0, 1)) # Convert from [1, 1, H, W] to [H, W]
|
31 |
+
|
32 |
mask = Image.fromarray(np.uint8(mat * 255), "L")
|
33 |
mask = mask.convert("RGB")
|
34 |
mask = mask.resize(image.size)
|