Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -431,29 +431,19 @@ def perform_object_detection(image_pil):
|
|
| 431 |
center_x = (bbox[0] + bbox[2]) / 2
|
| 432 |
center_y = (bbox[1] + bbox[3]) / 2
|
| 433 |
|
| 434 |
-
|
| 435 |
-
if x_center < image.size[0] / 2 and y_center < image.size[1] / 2:
|
| 436 |
-
position = 'Top-Left'
|
| 437 |
-
elif x_center >= image.size[0] / 2 and y_center < image.size[1] / 2:
|
| 438 |
-
position = 'Top-Right'
|
| 439 |
-
elif x_center < image.size[0] / 2 and y_center >= image.size[1] / 2:
|
| 440 |
-
position = 'Bottom-Left'
|
| 441 |
-
else:
|
| 442 |
-
position = 'Bottom-Right'
|
| 443 |
-
"""
|
| 444 |
-
if center_x < img_width / 3:
|
| 445 |
horiz = 'Left'
|
| 446 |
-
elif center_x
|
| 447 |
-
horiz = 'Center'
|
| 448 |
-
else:
|
| 449 |
horiz = 'Right'
|
|
|
|
|
|
|
| 450 |
|
| 451 |
-
if center_y < img_height /
|
| 452 |
vert = 'Top'
|
| 453 |
-
elif center_y
|
| 454 |
-
vert = 'Middle'
|
| 455 |
-
else:
|
| 456 |
vert = 'Bottom'
|
|
|
|
|
|
|
| 457 |
car_positions.append(f"{vert}-{horiz}")
|
| 458 |
|
| 459 |
elif cls_id == 0:
|
|
@@ -469,7 +459,6 @@ def perform_object_detection(image_pil):
|
|
| 469 |
|
| 470 |
# Calculate coverage area ratio
|
| 471 |
car_coverage_ratio = car_coverage_area / image_area *100 if image_area > 0 else 0
|
| 472 |
-
car_coverage_ratio = image_area if image_area > 0 else 0
|
| 473 |
car_coverage_ratio = round(car_coverage_ratio, 2)
|
| 474 |
|
| 475 |
# Get unique positions
|
|
|
|
| 431 |
center_x = (bbox[0] + bbox[2]) / 2
|
| 432 |
center_y = (bbox[1] + bbox[3]) / 2
|
| 433 |
|
| 434 |
+
if center_x < 2 * img_width * / 5:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
horiz = 'Left'
|
| 436 |
+
elif center_x > 3 * img_width / 5:
|
|
|
|
|
|
|
| 437 |
horiz = 'Right'
|
| 438 |
+
else:
|
| 439 |
+
horiz = 'Center'
|
| 440 |
|
| 441 |
+
if center_y < 2 * img_height / 5:
|
| 442 |
vert = 'Top'
|
| 443 |
+
elif center_y > 3 * img_height / 5:
|
|
|
|
|
|
|
| 444 |
vert = 'Bottom'
|
| 445 |
+
else:
|
| 446 |
+
vert = 'Middle'
|
| 447 |
car_positions.append(f"{vert}-{horiz}")
|
| 448 |
|
| 449 |
elif cls_id == 0:
|
|
|
|
| 459 |
|
| 460 |
# Calculate coverage area ratio
|
| 461 |
car_coverage_ratio = car_coverage_area / image_area *100 if image_area > 0 else 0
|
|
|
|
| 462 |
car_coverage_ratio = round(car_coverage_ratio, 2)
|
| 463 |
|
| 464 |
# Get unique positions
|