Spaces:
Sleeping
Sleeping
Commit
·
8756a23
1
Parent(s):
4526494
image addded
Browse files
app.py
CHANGED
@@ -49,17 +49,19 @@ def detect_using_clip(image,prompts=[],threshould=0.4):
|
|
49 |
# extract countours from the image
|
50 |
lbl_0 = label(predicted_image)
|
51 |
props = regionprops(lbl_0)
|
52 |
-
|
|
|
53 |
|
54 |
return model_detections
|
55 |
|
56 |
def visualize_images(image,detections,prompt):
|
57 |
H,W = image.shape[:2]
|
|
|
58 |
image_copy = image.copy()
|
59 |
if prompt not in detections.keys():
|
60 |
print("prompt not in query ..")
|
61 |
return image_copy
|
62 |
-
for bbox in detections[prompt
|
63 |
cv2.rectangle(image_copy, (int(bbox[1]), int(bbox[0])), (int(bbox[3]), int(bbox[2])), (255, 0, 0), 2)
|
64 |
cv2.putText(image_copy,str(prompt),(int(bbox[1]), int(bbox[0])),cv2.FONT_HERSHEY_SIMPLEX, 2, 255)
|
65 |
return image_copy
|
|
|
49 |
# extract countours from the image
|
50 |
lbl_0 = label(predicted_image)
|
51 |
props = regionprops(lbl_0)
|
52 |
+
prompt = prompt.lower()
|
53 |
+
model_detections[prompt] = [rescale_bbox(prop.bbox,orig_image_shape=image.shape[:2],model_shape=predicted_image.shape[0]) for prop in props]
|
54 |
|
55 |
return model_detections
|
56 |
|
57 |
def visualize_images(image,detections,prompt):
|
58 |
H,W = image.shape[:2]
|
59 |
+
prompt = prompt.lower()
|
60 |
image_copy = image.copy()
|
61 |
if prompt not in detections.keys():
|
62 |
print("prompt not in query ..")
|
63 |
return image_copy
|
64 |
+
for bbox in detections[prompt]:
|
65 |
cv2.rectangle(image_copy, (int(bbox[1]), int(bbox[0])), (int(bbox[3]), int(bbox[2])), (255, 0, 0), 2)
|
66 |
cv2.putText(image_copy,str(prompt),(int(bbox[1]), int(bbox[0])),cv2.FONT_HERSHEY_SIMPLEX, 2, 255)
|
67 |
return image_copy
|