Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,7 @@ async def predict(file: UploadFile = File(...)):
|
|
31 |
logits = outputs.logits # (batch, num_labels, H, W)
|
32 |
mask = torch.argmax(logits, dim=1)[0].numpy().astype(np.uint8)
|
33 |
|
34 |
-
#
|
35 |
mask_img = Image.fromarray(mask)
|
36 |
buf = BytesIO()
|
37 |
mask_img.save(buf, format="PNG")
|
|
|
31 |
logits = outputs.logits # (batch, num_labels, H, W)
|
32 |
mask = torch.argmax(logits, dim=1)[0].numpy().astype(np.uint8)
|
33 |
|
34 |
+
# Convert mask to grayscale PNG and return as base64
|
35 |
mask_img = Image.fromarray(mask)
|
36 |
buf = BytesIO()
|
37 |
mask_img.save(buf, format="PNG")
|