Spaces:
Build error
Build error
Commit
·
fa460fe
1
Parent(s):
5d3ed81
Update app.py
Browse files
app.py
CHANGED
@@ -98,7 +98,7 @@ def inference(img):
|
|
98 |
|
99 |
box_locations = outputs["instances"].pred_boxes
|
100 |
box_loc_screen = box_locations.tensor.cpu().numpy()
|
101 |
-
|
102 |
for i, box_coord in enumerate(box_loc_screen):
|
103 |
x0, y0, x1, y1 = box_coord
|
104 |
width = x1 - x0
|
@@ -113,9 +113,11 @@ def inference(img):
|
|
113 |
"h": int(height),
|
114 |
}
|
115 |
)
|
116 |
-
|
|
|
117 |
f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width: {int(width)} Height: {int(height)}"
|
118 |
-
|
|
|
119 |
|
120 |
|
121 |
output_str = "Imagine you are an intelligent image captioner. Describe each object in detail separately, in a scene where the X,Y coordinates and width,height of each object is given below. In the end give an overall summary of the scene\n"
|
|
|
98 |
|
99 |
box_locations = outputs["instances"].pred_boxes
|
100 |
box_loc_screen = box_locations.tensor.cpu().numpy()
|
101 |
+
unique_object_dict = {}
|
102 |
for i, box_coord in enumerate(box_loc_screen):
|
103 |
x0, y0, x1, y1 = box_coord
|
104 |
width = x1 - x0
|
|
|
113 |
"h": int(height),
|
114 |
}
|
115 |
)
|
116 |
+
if (predicted_label not in unique_object_dict):
|
117 |
+
object_list_str.append(
|
118 |
f"{predicted_label} - X:{int(x0)} Y: {int(y0)} Width: {int(width)} Height: {int(height)}"
|
119 |
+
)
|
120 |
+
unique_object_dict[predicted_label] = 1
|
121 |
|
122 |
|
123 |
output_str = "Imagine you are an intelligent image captioner. Describe each object in detail separately, in a scene where the X,Y coordinates and width,height of each object is given below. In the end give an overall summary of the scene\n"
|