Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,11 +31,16 @@ def draw_detections(image, detections):
|
|
| 31 |
box = detection['box']
|
| 32 |
x_min, y_min = box['xmin'], box['ymin']
|
| 33 |
x_max, y_max = box['xmax'], box['ymax']
|
|
|
|
| 34 |
cv2.rectangle(np_image, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
|
|
|
|
| 37 |
final_image = cv2.cvtColor(np_image, cv2.COLOR_BGR2RGB)
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
def get_pipeline_prediction(threshold, pil_image):
|
| 41 |
global od_pipe
|
|
|
|
| 31 |
box = detection['box']
|
| 32 |
x_min, y_min = box['xmin'], box['ymin']
|
| 33 |
x_max, y_max = box['xmax'], box['ymax']
|
| 34 |
+
# Draw rectangles and text with a larger font
|
| 35 |
cv2.rectangle(np_image, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
| 36 |
+
label_text = f'{label} {score:.2f}'
|
| 37 |
+
# Increase the font size and text thickness
|
| 38 |
+
cv2.putText(np_image, label_text, (x_min, y_min - 10), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 4)
|
| 39 |
|
| 40 |
+
# Convert BGR to RGB for displaying
|
| 41 |
final_image = cv2.cvtColor(np_image, cv2.COLOR_BGR2RGB)
|
| 42 |
+
final_pil_image = Image.fromarray(final_image)
|
| 43 |
+
return final_pil_image
|
| 44 |
|
| 45 |
def get_pipeline_prediction(threshold, pil_image):
|
| 46 |
global od_pipe
|