Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ def segment_everything(
|
|
| 47 |
|
| 48 |
|
| 49 |
annotations = results[0].masks.data
|
| 50 |
-
|
| 51 |
image=input,
|
| 52 |
device=device,
|
| 53 |
scale=(1024 // input_size),
|
|
@@ -57,8 +57,6 @@ def segment_everything(
|
|
| 57 |
use_retina=use_retina,
|
| 58 |
withContours=withContours,)
|
| 59 |
|
| 60 |
-
print('Figure',fig)
|
| 61 |
-
print('-----------')
|
| 62 |
bboxes = results[0].boxes.data
|
| 63 |
areas = (bboxes[:, 2] - bboxes[:, 0]) * (bboxes[:, 3] - bboxes[:, 1])
|
| 64 |
_, largest_indices = torch.topk(areas, 2)
|
|
@@ -82,10 +80,8 @@ def segment_everything(
|
|
| 82 |
|
| 83 |
cropped_img = Image.open(buf).convert("RGBA")
|
| 84 |
cropped_img = cropped_img.resize((1024, 682))
|
| 85 |
-
print('Crop type',cropped_img)
|
| 86 |
-
print('-----------')
|
| 87 |
|
| 88 |
-
return
|
| 89 |
|
| 90 |
title = "<center><strong><font size='8'>π Fast Segment Anything π€</font></strong></center>"
|
| 91 |
description = """ # π― Instructions for points mode """
|
|
@@ -106,6 +102,7 @@ demo = gr.Interface(
|
|
| 106 |
],
|
| 107 |
outputs = [
|
| 108 |
gr.Image(label="Segmented Image", interactive=False, type='pil')
|
|
|
|
| 109 |
],
|
| 110 |
title = title,
|
| 111 |
description = description,
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
annotations = results[0].masks.data
|
| 50 |
+
segmented_img = fast_process(annotations=annotations,
|
| 51 |
image=input,
|
| 52 |
device=device,
|
| 53 |
scale=(1024 // input_size),
|
|
|
|
| 57 |
use_retina=use_retina,
|
| 58 |
withContours=withContours,)
|
| 59 |
|
|
|
|
|
|
|
| 60 |
bboxes = results[0].boxes.data
|
| 61 |
areas = (bboxes[:, 2] - bboxes[:, 0]) * (bboxes[:, 3] - bboxes[:, 1])
|
| 62 |
_, largest_indices = torch.topk(areas, 2)
|
|
|
|
| 80 |
|
| 81 |
cropped_img = Image.open(buf).convert("RGBA")
|
| 82 |
cropped_img = cropped_img.resize((1024, 682))
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
return segmented_img, cropped_img
|
| 85 |
|
| 86 |
title = "<center><strong><font size='8'>π Fast Segment Anything π€</font></strong></center>"
|
| 87 |
description = """ # π― Instructions for points mode """
|
|
|
|
| 102 |
],
|
| 103 |
outputs = [
|
| 104 |
gr.Image(label="Segmented Image", interactive=False, type='pil')
|
| 105 |
+
gr.Image(label="Cropped Image", interactive=False, type='pil')
|
| 106 |
],
|
| 107 |
title = title,
|
| 108 |
description = description,
|