Skip to content

Commit 6cc08ba

Browse files
committed
Fix tests on Windows
1 parent 200fb11 commit 6cc08ba

File tree

3 files changed

+53
-92
lines changed

3 files changed

+53
-92
lines changed

superannotate/input_converters/export_from_sa_conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _move_files(data_set, src, platform):
7979
if data_set is not None:
8080
for tup in data_set:
8181
for i in tup:
82-
shutil.copy(i, os.path.join(train_path, i.split('/')[-1]))
82+
shutil.copy(i, os.path.join(train_path, os.path.basename(i)))
8383

8484

8585
def _create_classes_mapper(imgs, classes_json):

tests/converter_test/test_coco.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def coco_vector_instance(tmpdir):
2626
sa.upload_images_from_folder_to_project(project, out_dir)
2727
sa.upload_annotations_from_folder_to_project(project, out_dir)
2828

29-
return 0
30-
3129

3230
def coco_vector_object(tmpdir):
3331
out_dir = tmpdir / "object_vector"
@@ -49,7 +47,6 @@ def coco_vector_object(tmpdir):
4947
# )
5048
# sa.upload_images_from_folder_to_project(project, out_dir)
5149
# sa.upload_annotations_from_folder_to_project(project, out_dir)
52-
return 0
5350

5451

5552
def coco_pixel_instance(tmpdir):
@@ -73,8 +70,6 @@ def coco_pixel_instance(tmpdir):
7370
sa.upload_images_from_folder_to_project(project, out_dir)
7471
sa.upload_annotations_from_folder_to_project(project, out_dir)
7572

76-
return 0
77-
7873

7974
def coco_vector_keypoint(tmpdir):
8075
out_dir = tmpdir / "vector_keypoint"
@@ -97,8 +92,6 @@ def coco_vector_keypoint(tmpdir):
9792
sa.upload_images_from_folder_to_project(project, out_dir)
9893
sa.upload_annotations_from_folder_to_project(project, out_dir)
9994

100-
return 0
101-
10295

10396
def coco_desktop_object(tmpdir):
10497
out_dir = tmpdir / "coco_from_desktop"
@@ -134,12 +127,10 @@ def coco_desktop_object(tmpdir):
134127
sa.upload_images_from_folder_to_project(project, final_dir)
135128
sa.upload_annotations_from_folder_to_project(project, final_dir)
136129

137-
return 0
138-
139130

140131
def test_coco(tmpdir):
141-
assert coco_vector_instance(tmpdir) == 0
142-
assert coco_vector_object(tmpdir) == 0
143-
assert coco_pixel_instance(tmpdir) == 0
144-
assert coco_vector_keypoint(tmpdir) == 0
145-
assert coco_desktop_object(tmpdir) == 0
132+
coco_vector_instance(tmpdir)
133+
coco_vector_object(tmpdir)
134+
coco_pixel_instance(tmpdir)
135+
coco_vector_keypoint(tmpdir)
136+
coco_desktop_object(tmpdir)

tests/converter_test/test_conversion.py

Lines changed: 47 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,108 +6,78 @@
66
# COCO to SA
77
# test panoptic-segmentation
88
def panoptic_segmentation_coco2sa(tmpdir):
9-
out_path = tmpdir / "toSuperAnnotate/panoptic_test"
10-
try:
11-
sa.import_annotation_format(
12-
"tests/converter_test/COCO/input/toSuperAnnotate/panoptic_segmentation",
13-
str(out_path), "COCO", "panoptic_test", "Pixel",
14-
"panoptic_segmentation"
15-
)
16-
except Exception as e:
17-
return 1
18-
return 0
9+
out_path = tmpdir / "toSuperAnnotate" / "panoptic_test"
10+
sa.import_annotation_format(
11+
"tests/converter_test/COCO/input/toSuperAnnotate/panoptic_segmentation",
12+
str(out_path), "COCO", "panoptic_test", "Pixel", "panoptic_segmentation"
13+
)
1914

2015

2116
# test keypoint-detection
2217
def keypoint_detection_coco2sa(tmpdir):
23-
out_path = tmpdir / "toSuperAnnotate/keypoint_test"
24-
try:
25-
sa.import_annotation_format(
26-
"tests/converter_test/COCO/input/toSuperAnnotate/keypoint_detection",
27-
str(out_path), "COCO", "person_keypoints_test", "Vector",
28-
"keypoint_detection"
29-
)
30-
except Exception as e:
31-
return 1
32-
return 0
18+
out_path = tmpdir / "toSuperAnnotate" / "keypoint_test"
19+
sa.import_annotation_format(
20+
"tests/converter_test/COCO/input/toSuperAnnotate/keypoint_detection",
21+
str(out_path), "COCO", "person_keypoints_test", "Vector",
22+
"keypoint_detection"
23+
)
3324

3425

3526
# test instance segmentation
3627
def instance_segmentation_coco2sa(tmpdir):
37-
out_path = tmpdir / "toSuperAnnotate/instances_test"
38-
try:
39-
sa.import_annotation_format(
40-
"tests/converter_test/COCO/input/toSuperAnnotate/instance_segmentation",
41-
str(out_path), "COCO", "instances_test", "Vector",
42-
"instance_segmentation"
43-
)
44-
except Exception as e:
45-
return 1
46-
return 0
28+
out_path = tmpdir / "toSuperAnnotate" / "instances_test"
29+
sa.import_annotation_format(
30+
"tests/converter_test/COCO/input/toSuperAnnotate/instance_segmentation",
31+
str(out_path), "COCO", "instances_test", "Vector",
32+
"instance_segmentation"
33+
)
4734

4835

4936
# SA to COCO
5037
# test panoptic segmentation
5138
def panoptic_segmentation_sa2coco(tmpdir):
52-
out_path = tmpdir / "fromSuperAnnotate/panoptic_test"
53-
try:
54-
sa.export_annotation_format(
55-
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_panoptic_segm",
56-
str(out_path), "COCO", "panoptic_test", "Pixel",
57-
"panoptic_segmentation"
58-
)
59-
except Exception as e:
60-
return 1
61-
return 0
39+
out_path = tmpdir / "fromSuperAnnotate" / "panoptic_test"
40+
sa.export_annotation_format(
41+
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_panoptic_segm",
42+
str(out_path), "COCO", "panoptic_test", "Pixel", "panoptic_segmentation"
43+
)
6244

6345

6446
def keypoint_detection_sa2coco(tmpdir):
65-
out_path = tmpdir / "fromSuperAnnotate/keypoint_test_vector"
66-
try:
67-
sa.export_annotation_format(
68-
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_vector_keypoint_det",
69-
str(out_path), "COCO", "keypoint_test_vector", "Vector",
70-
"keypoint_detection"
71-
)
72-
except Exception as e:
73-
return 1
74-
return 0
47+
out_path = tmpdir / "fromSuperAnnotate" / "keypoint_test_vector"
48+
sa.export_annotation_format(
49+
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_vector_keypoint_det",
50+
str(out_path), "COCO", "keypoint_test_vector", "Vector",
51+
"keypoint_detection"
52+
)
7553

7654

7755
def instance_segmentation_sa2coco_pixel(tmpdir):
78-
out_path = tmpdir / "fromSuperAnnotate/instance_test_pixel"
79-
try:
80-
sa.export_annotation_format(
81-
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_pixel_instance_segm",
82-
str(out_path), "COCO", "instance_test_pixel", "Pixel",
83-
"instance_segmentation"
84-
)
85-
except Exception as e:
86-
return 1
87-
return 0
56+
out_path = tmpdir / "fromSuperAnnotate" / "instance_test_pixel"
57+
sa.export_annotation_format(
58+
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_pixel_instance_segm",
59+
str(out_path), "COCO", "instance_test_pixel", "Pixel",
60+
"instance_segmentation"
61+
)
8862

8963

9064
def instance_segmentation_sa2coco_vector(tmpdir):
91-
out_path = tmpdir / "fromSuperAnnotate/instance_test_vector"
92-
try:
93-
sa.export_annotation_format(
94-
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_vector_instance_segm",
95-
str(out_path), "COCO", "instance_test_vector", "Vector",
96-
"instance_segmentation"
97-
)
98-
except Exception as e:
99-
return 1
100-
return 0
65+
out_path = tmpdir / "fromSuperAnnotate" / "instance_test_vector"
66+
sa.export_annotation_format(
67+
"tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_vector_instance_segm",
68+
str(out_path), "COCO", "instance_test_vector", "Vector",
69+
"instance_segmentation"
70+
)
10171

10272

10373
def test_coco2sa(tmpdir):
104-
assert panoptic_segmentation_coco2sa(tmpdir) == 0
105-
assert keypoint_detection_coco2sa(tmpdir) == 0
106-
assert instance_segmentation_coco2sa(tmpdir) == 0
74+
panoptic_segmentation_coco2sa(tmpdir)
75+
keypoint_detection_coco2sa(tmpdir)
76+
instance_segmentation_coco2sa(tmpdir)
10777

10878

10979
def test_sa2coco(tmpdir):
110-
assert panoptic_segmentation_sa2coco(tmpdir) == 0
111-
assert keypoint_detection_sa2coco(tmpdir) == 0
112-
assert instance_segmentation_sa2coco_pixel(tmpdir) == 0
113-
assert instance_segmentation_sa2coco_vector(tmpdir) == 0
80+
panoptic_segmentation_sa2coco(tmpdir)
81+
keypoint_detection_sa2coco(tmpdir)
82+
instance_segmentation_sa2coco_pixel(tmpdir)
83+
instance_segmentation_sa2coco_vector(tmpdir)

0 commit comments

Comments
 (0)