Skip to content

Commit 6f8f733

Browse files
committed
test corrected
1 parent 4506e37 commit 6f8f733

File tree

10 files changed

+312
-329
lines changed

10 files changed

+312
-329
lines changed

tests/converter_test/test_coco.py

Lines changed: 53 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,121 +5,102 @@
55
import superannotate as sa
66

77

8-
def test_coco_vector_instance(tmpdir):
9-
input_dir = Path(
10-
"tests"
11-
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
12-
out_dir = Path(tmpdir) / "instance_vector"
13-
sa.import_annotation(
14-
input_dir, out_dir, "COCO", "instances_test", "Vector",
15-
"instance_segmentation"
16-
)
17-
18-
project_name = "coco2sa_vector_instance"
19-
8+
def upload_project(project_path, project_name, description, ptype):
209
projects = sa.search_projects(project_name, True)
2110
if projects:
2211
sa.delete_project(projects[0])
23-
project = sa.create_project(project_name, "converter vector", "Vector")
12+
project = sa.create_project(project_name, description, ptype)
2413

2514
sa.create_annotation_classes_from_classes_json(
26-
project, out_dir / "classes" / "classes.json"
15+
project, project_path / "classes" / "classes.json"
2716
)
28-
sa.upload_images_from_folder_to_project(project, out_dir)
29-
sa.upload_annotations_from_folder_to_project(project, out_dir)
17+
sa.upload_images_from_folder_to_project(project, project_path)
18+
sa.upload_annotations_from_folder_to_project(project, project_path)
3019

3120

32-
def test_coco_vector_object(tmpdir):
21+
def test_coco_vector_instance(tmpdir):
22+
project_name = "coco2sa_vector_instance"
23+
3324
input_dir = Path(
3425
"tests"
3526
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
36-
out_dir = Path(tmpdir) / "object_vector_desktop"
27+
out_dir = Path(tmpdir) / project_name
3728
sa.import_annotation(
3829
input_dir, out_dir, "COCO", "instances_test", "Vector",
39-
"object_detection"
30+
"instance_segmentation"
4031
)
4132

33+
description = 'coco vector instance segmentation'
34+
ptype = 'Vector'
35+
upload_project(out_dir, project_name, description, ptype)
36+
37+
38+
def test_coco_vector_object(tmpdir):
39+
project_name = "coco2sa_vector_object"
4240

43-
def test_coco_vector_object2(tmpdir):
4441
input_dir = Path(
4542
"tests"
4643
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
47-
out_dir = Path(tmpdir) / "object_vector_object_new"
44+
out_dir = Path(tmpdir) / project_name
4845
sa.import_annotation(
4946
input_dir, out_dir, "COCO", "instances_test", "Vector",
5047
"object_detection"
5148
)
52-
project_name = "coco2sa_vector_object"
5349

54-
projects = sa.search_projects(project_name, True)
55-
if projects:
56-
sa.delete_project(projects[0])
57-
project = sa.create_project(project_name, "converter vector", "Vector")
50+
description = 'coco vector object detection'
51+
ptype = 'Vector'
52+
upload_project(out_dir, project_name, description, ptype)
5853

59-
sa.create_annotation_classes_from_classes_json(
60-
project, out_dir / "classes" / "classes.json"
61-
)
62-
sa.upload_images_from_folder_to_project(project, out_dir)
63-
sa.upload_annotations_from_folder_to_project(project, out_dir)
6454

55+
def test_coco_vector_keypoint(tmpdir):
56+
project_name = "coco2sa_keypoint"
6557

66-
def test_coco_vector_object_instance(tmpdir):
6758
input_dir = Path(
6859
"tests"
69-
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
70-
out_dir = Path(tmpdir) / "object_vector_instance_desktop"
60+
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "keypoint_detection/"
61+
out_dir = Path(tmpdir) / project_name
7162
sa.import_annotation(
72-
input_dir, out_dir, "COCO", "instances_test", "Vector",
73-
"instance_segmentation"
63+
input_dir, out_dir, "COCO", "person_keypoints_test", "Vector",
64+
"keypoint_detection"
7465
)
7566

67+
description = 'coco vector keypoint detection'
68+
ptype = 'Vector'
69+
upload_project(out_dir, project_name, description, ptype)
70+
71+
72+
def test_coco_panoptic(tmpdir):
73+
project_name = "coco2sa_panoptic"
7674

77-
def test_coco_pixel_instance(tmpdir):
7875
input_dir = Path(
7976
"tests"
80-
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
81-
out_dir = Path(tmpdir) / "instance_pixel"
77+
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "panoptic_segmentation"
78+
out_dir = Path(tmpdir) / project_name
8279
sa.import_annotation(
83-
input_dir, out_dir, "COCO", "instances_test", "Pixel",
84-
"instance_segmentation"
80+
input_dir, out_dir, "COCO", "panoptic_test", "Pixel",
81+
"panoptic_segmentation"
8582
)
8683

87-
project_name = "coco2sa_pixel_instance"
84+
description = 'coco pixel panoptic segmentation'
85+
ptype = 'Pixel'
86+
upload_project(out_dir, project_name, description, ptype)
8887

89-
projects = sa.search_projects(project_name, True)
90-
if projects:
91-
sa.delete_project(projects[0])
92-
project = sa.create_project(project_name, "converter vector", "Pixel")
93-
94-
sa.create_annotation_classes_from_classes_json(
95-
project, out_dir / "classes" / "classes.json"
96-
)
97-
sa.upload_images_from_folder_to_project(project, out_dir)
98-
sa.upload_annotations_from_folder_to_project(project, out_dir)
9988

89+
def test_coco_pixel_instance(tmpdir):
90+
project_name = "coco2sa_pixel_instance"
10091

101-
def test_coco_vector_keypoint(tmpdir):
10292
input_dir = Path(
10393
"tests"
104-
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "keypoint_detection/"
105-
out_dir = Path(tmpdir) / "vector_keypoint"
94+
) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
95+
out_dir = Path(tmpdir) / project_name
10696
sa.import_annotation(
107-
input_dir, out_dir, "COCO", "person_keypoints_test", "Vector",
108-
"keypoint_detection"
97+
input_dir, out_dir, "COCO", "instances_test", "Pixel",
98+
"instance_segmentation"
10999
)
110100

111-
project_name = "coco2sa_keypoint"
112-
113-
projects = sa.search_projects(project_name, True)
114-
if projects:
115-
sa.delete_project(projects[0])
116-
project = sa.create_project(project_name, "converter vector", "Vector")
117-
118-
sa.create_annotation_classes_from_classes_json(
119-
project, out_dir / "classes" / "classes.json"
120-
)
121-
sa.upload_images_from_folder_to_project(project, out_dir)
122-
sa.upload_annotations_from_folder_to_project(project, out_dir)
101+
description = 'coco pixel instance segmentation'
102+
ptype = 'Pixel'
103+
upload_project(out_dir, project_name, description, ptype)
123104

124105

125106
def test_sa_to_coco_to_sa(tmpdir):
@@ -138,13 +119,6 @@ def test_sa_to_coco_to_sa(tmpdir):
138119
)
139120

140121
project_name = 'coco_pipeline_new'
141-
project = sa.search_projects(project_name, return_metadata=True)
142-
for pr in project:
143-
sa.delete_project(pr)
144-
145-
project = sa.create_project(project_name, 'test_instane', 'Pixel')
146-
sa.upload_images_from_folder_to_project(project, output2)
147-
sa.create_annotation_classes_from_classes_json(
148-
project, output2 / "classes" / "classes.json"
149-
)
150-
sa.upload_annotations_from_folder_to_project(project, output2)
122+
description = 'test_instane'
123+
ptype = 'Pixel'
124+
upload_project(output2, project_name, description, ptype)

tests/converter_test/test_dataloop.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,61 @@
33
import superannotate as sa
44

55

6+
def upload_project(project_path, project_name, description, ptype):
7+
projects = sa.search_projects(project_name, True)
8+
if projects:
9+
sa.delete_project(projects[0])
10+
project = sa.create_project(project_name, description, ptype)
11+
12+
sa.create_annotation_classes_from_classes_json(
13+
project, project_path / "classes" / "classes.json"
14+
)
15+
sa.upload_images_from_folder_to_project(project, project_path)
16+
sa.upload_annotations_from_folder_to_project(project, project_path)
17+
18+
619
def test_dataloop_convert_vector(tmpdir):
20+
project_name = "dataloop2sa_vector_annotation"
21+
722
input_dir = Path(
823
'tests'
924
) / 'converter_test' / 'DataLoop' / 'input' / 'toSuperAnnotate'
10-
out_dir = Path(tmpdir) / 'output_vector'
25+
out_dir = Path(tmpdir) / project_name
1126
sa.import_annotation(
1227
input_dir, out_dir, 'DataLoop', '', 'Vector', 'vector_annotation'
1328
)
14-
project_name = "dataloop_test_vector"
1529

16-
projects = sa.search_projects(project_name, True)
17-
if projects:
18-
sa.delete_project(projects[0])
19-
project = sa.create_project(project_name, "converter vector", "Vector")
20-
21-
sa.create_annotation_classes_from_classes_json(
22-
project, out_dir / "classes" / "classes.json"
23-
)
24-
sa.upload_images_from_folder_to_project(project, out_dir)
25-
sa.upload_annotations_from_folder_to_project(project, out_dir)
30+
description = 'dataloop vector annotation'
31+
ptype = 'Vector'
32+
upload_project(out_dir, project_name, description, ptype)
2633

2734

2835
def test_dataloop_convert_object(tmpdir):
36+
project_name = "dataloop2sa_vector_object"
37+
2938
input_dir = Path(
3039
'tests'
3140
) / 'converter_test' / 'DataLoop' / 'input' / 'toSuperAnnotate'
32-
out_dir = Path(tmpdir) / 'output_object'
41+
out_dir = Path(tmpdir) / project_name
3342
sa.import_annotation(
3443
input_dir, out_dir, 'DataLoop', '', 'Vector', 'object_detection'
3544
)
3645

46+
description = 'dataloop object detection'
47+
ptype = 'Vector'
48+
upload_project(out_dir, project_name, description, ptype)
49+
3750

3851
def test_dataloop_convert_instance(tmpdir):
52+
project_name = "dataloop2sa_vector_instance"
53+
3954
input_dir = Path(
4055
'tests'
4156
) / 'converter_test' / 'DataLoop' / 'input' / 'toSuperAnnotate'
42-
out_dir = Path(tmpdir) / 'output_instance'
57+
out_dir = Path(tmpdir) / project_name
4358
sa.import_annotation(
4459
input_dir, out_dir, 'DataLoop', '', 'Vector', 'instance_segmentation'
4560
)
46-
project_name = "dataloop_test_instance"
47-
48-
projects = sa.search_projects(project_name, True)
49-
if projects:
50-
sa.delete_project(projects[0])
51-
project = sa.create_project(project_name, "converter vector", "Vector")
52-
53-
sa.create_annotation_classes_from_classes_json(
54-
project, out_dir / "classes" / "classes.json"
55-
)
56-
sa.upload_images_from_folder_to_project(project, out_dir)
57-
sa.upload_annotations_from_folder_to_project(project, out_dir)
61+
description = 'dataloop instance segmentation'
62+
ptype = 'Vector'
63+
upload_project(out_dir, project_name, description, ptype)

tests/converter_test/test_googlecloud.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,31 @@
22
import superannotate as sa
33

44

5-
def test_googlecloud_convert_web(tmpdir):
6-
input_dir = Path(
7-
"tests"
8-
) / "converter_test" / "GoogleCloud" / "input" / "toSuperAnnotate"
9-
out_dir = Path(tmpdir) / "output_web"
10-
sa.import_annotation(
11-
input_dir, out_dir, "GoogleCloud", "image_object_detection", "Vector",
12-
"object_detection"
13-
)
14-
15-
project_name = "googlcloud_vector"
16-
5+
def upload_project(project_path, project_name, description, ptype):
176
projects = sa.search_projects(project_name, True)
187
if projects:
198
sa.delete_project(projects[0])
20-
project = sa.create_project(project_name, "converter vector", "Vector")
9+
project = sa.create_project(project_name, description, ptype)
2110

2211
sa.create_annotation_classes_from_classes_json(
23-
project, out_dir / "classes" / "classes.json"
12+
project, project_path / "classes" / "classes.json"
2413
)
25-
sa.upload_images_from_folder_to_project(project, out_dir)
26-
sa.upload_annotations_from_folder_to_project(project, out_dir)
14+
sa.upload_images_from_folder_to_project(project, project_path)
15+
sa.upload_annotations_from_folder_to_project(project, project_path)
2716

2817

29-
def test_googlecloud_convert_desktop(tmpdir):
18+
def test_googlecloud_convert_web(tmpdir):
19+
project_name = "googlcloud_object"
20+
3021
input_dir = Path(
3122
"tests"
3223
) / "converter_test" / "GoogleCloud" / "input" / "toSuperAnnotate"
33-
out_dir = Path(tmpdir) / "output_desktop"
24+
out_dir = Path(tmpdir) / project_name
3425
sa.import_annotation(
3526
input_dir, out_dir, "GoogleCloud", "image_object_detection", "Vector",
3627
"object_detection"
3728
)
29+
30+
description = 'googlecloud object detection'
31+
ptype = 'Vector'
32+
upload_project(out_dir, project_name, description, ptype)

0 commit comments

Comments
 (0)