Skip to content

Commit 9979128

Browse files
owencjonesOwen
andauthored
Hotfix IO-1607 (#650)
Co-authored-by: Owen <[email protected]>
1 parent ba24df7 commit 9979128

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

darwin/exporter/formats/yolo_segmented.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,19 @@ def _handle_bounding_box(data: dict, im_w: int, im_h: int, annotation_index: int
109109
try:
110110
# Create 8 coordinates for the x,y pairs of the 4 corners
111111
x1, y1, x2, y2, x3, y3, x4, y4, x5, y5 = (
112+
# top left corner
112113
data["x"],
113114
data["y"],
115+
# top right corner
114116
(data["x"] + data["w"]),
115-
(data["y"] + data["h"]),
117+
(data["y"]),
118+
# bottom right
116119
(data["x"] + data["w"]),
117-
data["y"],
120+
(data["y"] + data["h"]),
121+
# bottom left
118122
data["x"],
119123
(data["y"] + data["h"]),
124+
# top left again to close the polygon
120125
data["x"],
121126
data["y"],
122127
)

tests/darwin/exporter/formats/export_yolo_segmented_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def test_export_yolo_segmented(annotation_files: List[AnnotationFile], tmp_path:
9898

9999
output_lines = (tmp_path / "file1.txt").read_text().splitlines()
100100
if CLOSE_VERTICES:
101-
assert output_lines[0] == "0 0.02 0.03 0.27 0.16 0.27 0.03 0.02 0.16 0.02 0.03"
101+
assert output_lines[0] == "0 0.02 0.03 0.27 0.03 0.27 0.16 0.02 0.16 0.02 0.03"
102102
assert output_lines[1] == "1 0.0 0.0 0.0 0.1 0.05 0.15 0.1 0.1 0.0 0.1 0.0 0.0 0.0 0.0"
103103
assert output_lines[2] == "2 0.0 0.0 0.0 0.1 0.05 0.15 0.1 0.1 0.0 0.1 0.0 0.0 0.0 0.0"
104104
else:
105-
assert output_lines[0] == "0 0.02 0.03 0.27 0.16 0.27 0.03 0.02 0.16"
105+
assert output_lines[0] == "0 0.02 0.03 0.27 0.03 0.27 0.16 0.02 0.16"
106106
assert output_lines[1] == "1 0.0 0.0 0.0 0.1 0.05 0.15 0.1 0.1 0.0 0.1 0.0 0.0"
107107
assert output_lines[2] == "2 0.0 0.0 0.0 0.1 0.05 0.15 0.1 0.1 0.0 0.1 0.0 0.0"

0 commit comments

Comments
 (0)