change json + description change
Browse files
app.py
CHANGED
@@ -100,7 +100,7 @@ def detect_objects(image, prompt, show_masks=True, show_boxes=True, crop_options
|
|
100 |
|
101 |
output_image_paths = []
|
102 |
|
103 |
-
for i, (input_box, label) in enumerate(zip(boxes, labels)):
|
104 |
x1, y1, x2, y2 = input_box
|
105 |
width = x2 - x1
|
106 |
height = y2 - y1
|
@@ -143,10 +143,14 @@ def detect_objects(image, prompt, show_masks=True, show_boxes=True, crop_options
|
|
143 |
output_image_paths.append(output_image_path)
|
144 |
|
145 |
# save object information in json
|
146 |
-
res_json["objects"].append(
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
150 |
|
151 |
return [res_json, output_image_paths]
|
152 |
|
@@ -171,9 +175,8 @@ app = gr.Interface(
|
|
171 |
["images/penguin.png", "penguin"],
|
172 |
["images/penn.jpg", "sign board"]
|
173 |
],
|
174 |
-
title="
|
175 |
-
description="
|
176 |
-
article="https://segment-anything.com",
|
177 |
)
|
178 |
|
179 |
app.launch()
|
|
|
100 |
|
101 |
output_image_paths = []
|
102 |
|
103 |
+
for i, (input_box, label, phrase, logit) in enumerate(zip(boxes, labels, phrases, logits.tolist())):
|
104 |
x1, y1, x2, y2 = input_box
|
105 |
width = x2 - x1
|
106 |
height = y2 - y1
|
|
|
143 |
output_image_paths.append(output_image_path)
|
144 |
|
145 |
# save object information in json
|
146 |
+
res_json["objects"].append({
|
147 |
+
"label": phrase,
|
148 |
+
"dino_score": logit,
|
149 |
+
"sam_score": np.max(scores).item(),
|
150 |
+
"box": input_box.tolist(),
|
151 |
+
"center": center_point.tolist(),
|
152 |
+
"avg_size": avg_size
|
153 |
+
})
|
154 |
|
155 |
return [res_json, output_image_paths]
|
156 |
|
|
|
175 |
["images/penguin.png", "penguin"],
|
176 |
["images/penn.jpg", "sign board"]
|
177 |
],
|
178 |
+
title="Object Detection, Segmentation and Cropping",
|
179 |
+
description="This app uses DINO to detect objects in an image and then uses SAM to segment and crop the objects.",
|
|
|
180 |
)
|
181 |
|
182 |
app.launch()
|