|
15 | 15 |
|
16 | 16 |
|
17 | 17 | def test_bbox_export(tmp_path):
|
18 |
| - ctx = YoloContext(annotation_type="bbox", path="data") |
| 18 | + ctx = YoloContext(annotation_type="bbox", path=Path("data")) |
19 | 19 | ctx.categories.add(name="cat")
|
20 | 20 | ctx.categories.add(name="dog")
|
21 | 21 | annotations = [
|
@@ -53,7 +53,7 @@ def test_bbox_export(tmp_path):
|
53 | 53 |
|
54 | 54 |
|
55 | 55 | def test_segmentation_export(tmp_path):
|
56 |
| - ctx = YoloContext(annotation_type="segmentation", path="data") |
| 56 | + ctx = YoloContext(annotation_type="segmentation", path=Path("data")) |
57 | 57 | ctx.categories.add(name="cat")
|
58 | 58 | ctx.categories.add(name="dog")
|
59 | 59 | annotations = [
|
@@ -85,7 +85,7 @@ def test_segmentation_export(tmp_path):
|
85 | 85 |
|
86 | 86 |
|
87 | 87 | def test_pose_export(tmp_path):
|
88 |
| - ctx = YoloContext(annotation_type="pose", path="data") |
| 88 | + ctx = YoloContext(annotation_type="pose", path=Path("data")) |
89 | 89 | ctx.categories.add(name="cat")
|
90 | 90 | ctx.categories.add(name="dog")
|
91 | 91 | ctx.keypoints_in_annotation = 2
|
@@ -118,7 +118,7 @@ def test_pose_export(tmp_path):
|
118 | 118 |
|
119 | 119 |
|
120 | 120 | def test_not_exporting_wrong_annotations(tmp_path):
|
121 |
| - ctx = YoloContext(annotation_type="bbox", path="data") |
| 121 | + ctx = YoloContext(annotation_type="bbox", path=Path("data")) |
122 | 122 | ctx.categories.add(name="cat")
|
123 | 123 | ctx.categories.add(name="dog")
|
124 | 124 | annotations = [
|
@@ -173,3 +173,41 @@ def test__get_common_folder_with_part(paths, prefix, expected):
|
173 | 173 | expected = Path(expected)
|
174 | 174 |
|
175 | 175 | assert actual == expected
|
| 176 | + |
| 177 | + |
| 178 | +def test_export_with_image_in_path(tmp_path): |
| 179 | + ctx = YoloContext(annotation_type="bbox", path=Path("data/images")) |
| 180 | + ctx.categories.add(name="cat") |
| 181 | + ctx.categories.add(name="dog") |
| 182 | + annotations = [ |
| 183 | + IRBBoxImageAnnotation( |
| 184 | + filename="cats/1.jpg", |
| 185 | + categories={"cat": 1.0}, |
| 186 | + top=0.0, |
| 187 | + left=0.0, |
| 188 | + width=0.5, |
| 189 | + height=0.5, |
| 190 | + image_width=100, |
| 191 | + image_height=200, |
| 192 | + coordinate_style=CoordinateStyle.NORMALIZED, |
| 193 | + ), |
| 194 | + IRBBoxImageAnnotation( |
| 195 | + filename="dogs/2.jpg", |
| 196 | + categories={"dog": 1.0}, |
| 197 | + top=0.5, |
| 198 | + left=0.5, |
| 199 | + width=0.5, |
| 200 | + height=0.5, |
| 201 | + image_width=100, |
| 202 | + image_height=200, |
| 203 | + coordinate_style=CoordinateStyle.NORMALIZED, |
| 204 | + ), |
| 205 | + ] |
| 206 | + |
| 207 | + p = export_to_fs(ctx, annotations, export_dir=tmp_path) |
| 208 | + |
| 209 | + assert p == tmp_path / "yolo_dagshub.yaml" |
| 210 | + |
| 211 | + assert (tmp_path / "yolo_dagshub.yaml").exists() |
| 212 | + assert (tmp_path / "data" / "labels" / "cats" / "1.txt").exists() |
| 213 | + assert (tmp_path / "data" / "labels" / "dogs" / "2.txt").exists() |
0 commit comments