Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,9 @@ import matplotlib.pyplot as plt
|
|
| 9 |
import matplotlib.patches as patches
|
| 10 |
import io
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
model = YOLO('./weights/FastSAM-x.pt')
|
| 13 |
|
| 14 |
device = torch.device(
|
|
@@ -60,7 +63,8 @@ def segment_everything(
|
|
| 60 |
largest_boxes = bboxes[largest_indices]
|
| 61 |
for i, box in enumerate(largest_boxes):
|
| 62 |
print(f"Largest Box {i+1}: {box.tolist()}")
|
| 63 |
-
|
|
|
|
| 64 |
fig, ax = plt.subplots(1)
|
| 65 |
ax.imshow(input)
|
| 66 |
|
|
@@ -68,7 +72,8 @@ def segment_everything(
|
|
| 68 |
x1, y1, x2, y2 = box[:4]
|
| 69 |
rect = patches.Rectangle((x1, y1), x2-x1, y2-y1, linewidth=2, edgecolor='r', facecolor='none')
|
| 70 |
ax.add_patch(rect)
|
| 71 |
-
|
|
|
|
| 72 |
ax.axis('off')
|
| 73 |
buf = io.BytesIO()
|
| 74 |
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)
|
|
|
|
| 9 |
import matplotlib.patches as patches
|
| 10 |
import io
|
| 11 |
|
| 12 |
+
import warnings
|
| 13 |
+
warnings.filterwarnings(action='ignore')
|
| 14 |
+
|
| 15 |
model = YOLO('./weights/FastSAM-x.pt')
|
| 16 |
|
| 17 |
device = torch.device(
|
|
|
|
| 63 |
largest_boxes = bboxes[largest_indices]
|
| 64 |
for i, box in enumerate(largest_boxes):
|
| 65 |
print(f"Largest Box {i+1}: {box.tolist()}")
|
| 66 |
+
|
| 67 |
+
print('Type',input)
|
| 68 |
fig, ax = plt.subplots(1)
|
| 69 |
ax.imshow(input)
|
| 70 |
|
|
|
|
| 72 |
x1, y1, x2, y2 = box[:4]
|
| 73 |
rect = patches.Rectangle((x1, y1), x2-x1, y2-y1, linewidth=2, edgecolor='r', facecolor='none')
|
| 74 |
ax.add_patch(rect)
|
| 75 |
+
|
| 76 |
+
print('Done till here')
|
| 77 |
ax.axis('off')
|
| 78 |
buf = io.BytesIO()
|
| 79 |
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)
|