Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -28,8 +28,8 @@ vehicle_threshold = 0.5
|
|
28 |
def bbox_normalization(bbox, width, height):
|
29 |
height_coeff = height/352
|
30 |
width_coeff = width/352
|
31 |
-
normalized_bbox = [
|
32 |
-
|
33 |
return normalized_bbox
|
34 |
|
35 |
def bbox_area(bbox):
|
@@ -47,7 +47,7 @@ def segment_to_bbox(segment_indexs):
|
|
47 |
if x_points and y_points:
|
48 |
return [np.min(x_points), np.min(y_points), np.max(x_points), np.max(y_points)]
|
49 |
else:
|
50 |
-
return [0,0,0,0]
|
51 |
|
52 |
def clipseg_prediction(image):
|
53 |
|
@@ -77,9 +77,9 @@ def clipseg_prediction(image):
|
|
77 |
|
78 |
# Vehicle checking
|
79 |
if bbox_area(vehicle_bbox) > bbox_area(damage_bbox):
|
80 |
-
return True, bbox_normalization(damage_bbox, img_w, img_h)
|
81 |
else:
|
82 |
-
return False, []
|
83 |
|
84 |
|
85 |
@torch.no_grad()
|
|
|
28 |
def bbox_normalization(bbox, width, height):
|
29 |
height_coeff = height/352
|
30 |
width_coeff = width/352
|
31 |
+
normalized_bbox = [bbox[0]*width_coeff, bbox[1]*height_coeff,
|
32 |
+
bbox[2]*width_coeff, bbox[3]*height_coeff]
|
33 |
return normalized_bbox
|
34 |
|
35 |
def bbox_area(bbox):
|
|
|
47 |
if x_points and y_points:
|
48 |
return [np.min(x_points), np.min(y_points), np.max(x_points), np.max(y_points)]
|
49 |
else:
|
50 |
+
return [0.0,0.0,0.0,0.0]
|
51 |
|
52 |
def clipseg_prediction(image):
|
53 |
|
|
|
77 |
|
78 |
# Vehicle checking
|
79 |
if bbox_area(vehicle_bbox) > bbox_area(damage_bbox):
|
80 |
+
return True, [bbox_normalization(damage_bbox, img_w, img_h)]
|
81 |
else:
|
82 |
+
return False, [[]]
|
83 |
|
84 |
|
85 |
@torch.no_grad()
|