Update app.py
Browse filesadded calc area function
app.py
CHANGED
@@ -77,6 +77,12 @@ def load_sam_predictor():
|
|
77 |
return False
|
78 |
return sam_predictor is not None
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
def filter_bbox_outliers(detections: List[Dict],
|
81 |
method: str = 'iqr',
|
82 |
threshold: float = 1.5,
|
|
|
77 |
return False
|
78 |
return sam_predictor is not None
|
79 |
|
80 |
+
def calculate_bbox_area(bbox: List[float]) -> float:
|
81 |
+
"""Calculate the area of a bounding box [x1, y1, x2, y2]"""
|
82 |
+
width = abs(bbox[2] - bbox[0])
|
83 |
+
height = abs(bbox[3] - bbox[1])
|
84 |
+
return width * height
|
85 |
+
|
86 |
def filter_bbox_outliers(detections: List[Dict],
|
87 |
method: str = 'iqr',
|
88 |
threshold: float = 1.5,
|