Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,10 @@ def segment_to_bbox(segment_indexs):
|
|
| 44 |
if val == 1:
|
| 45 |
x_points.append(x)
|
| 46 |
y_points.append(y)
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
def clipseg_prediction(image):
|
| 50 |
|
|
@@ -74,13 +77,13 @@ def clipseg_prediction(image):
|
|
| 74 |
|
| 75 |
# Vehicle checking
|
| 76 |
if bbox_area(vehicle_bbox) > bbox_area(damage_bbox):
|
| 77 |
-
return True, bbox_normalization(damage_bbox, img_w, img_h)
|
| 78 |
else:
|
| 79 |
return False, [[]]
|
| 80 |
|
| 81 |
|
| 82 |
@torch.no_grad()
|
| 83 |
-
def foward_pass(image_input: np.ndarray, points: List[int]) -> np.ndarray:
|
| 84 |
print('SAM-Segmentation-started------->')
|
| 85 |
global cache_data
|
| 86 |
image_input = Image.fromarray(image_input)
|
|
|
|
| 44 |
if val == 1:
|
| 45 |
x_points.append(x)
|
| 46 |
y_points.append(y)
|
| 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 |
|
| 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()
|
| 86 |
+
def foward_pass(image_input: np.ndarray, points: List[List[int]]) -> np.ndarray:
|
| 87 |
print('SAM-Segmentation-started------->')
|
| 88 |
global cache_data
|
| 89 |
image_input = Image.fromarray(image_input)
|