Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/superannotate/lib/infrastructure/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def search_annotation_classes(self, project_name: str, name_prefix: str = None):
classes=AnnotationClassRepository(
service=self._backend_client, project=project_entity
),
condition=condition
condition=condition,
)
return use_case.execute()

Expand Down
5 changes: 3 additions & 2 deletions src/superannotate/lib/infrastructure/services.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from contextlib import contextmanager
from datetime import datetime
from typing import Dict
Expand Down Expand Up @@ -27,7 +26,9 @@ class BaseBackendService(SuerannotateServiceProvider):
Base service class
"""

def __init__(self, api_url: str, auth_token: str, logger, paginate_by=None, verify_ssl=True):
def __init__(
self, api_url: str, auth_token: str, logger, paginate_by=None, verify_ssl=True
):
self.api_url = api_url
self._auth_token = auth_token
self.logger = logger
Expand Down
92 changes: 48 additions & 44 deletions tests/convertors/test_consensus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import tempfile
import time
from os.path import dirname

Expand Down Expand Up @@ -38,60 +39,63 @@ def test_consensus(self):
"folderName",
"score",
]
export_path = self.export_path
for i in range(1, 4):
sa.create_folder(self.PROJECT_NAME, "consensus_" + str(i))
sa.create_annotation_classes_from_classes_json(
self.PROJECT_NAME, self.export_path + "/classes/classes.json"
)
sa.upload_images_from_folder_to_project(
self.PROJECT_NAME,
self.export_path + "/images",
annotation_status="Completed",
)
for i in range(1, 4):

with tempfile.TemporaryDirectory() as tmpdir:
temp_export_path = str(tmpdir)

for i in range(1, 4):
sa.create_folder(self.PROJECT_NAME, "consensus_" + str(i))
sa.create_annotation_classes_from_classes_json(
self.PROJECT_NAME, self.export_path + "/classes/classes.json"
)
sa.upload_images_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.PROJECT_NAME,
self.export_path + "/images",
annotation_status="Completed",
)
time.sleep(2)
sa.upload_annotations_from_folder_to_project(
self.PROJECT_NAME, self.export_path
)
for i in range(1, 4):
for i in range(1, 4):
sa.upload_images_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.export_path + "/images",
annotation_status="Completed",
)
time.sleep(2)
sa.upload_annotations_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.export_path + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.PROJECT_NAME, self.export_path
)
for i in range(1, 4):
sa.upload_annotations_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.export_path + f"/{self.CONSENSUS_PREFIX}" + str(i),
)

for annot_type in annot_types:
res_df = sa.consensus(
self.PROJECT_NAME, folder_names, annot_type=annot_type
)
# test content of projectName column
assert sorted(res_df["folderName"].unique()) == folder_names
for annot_type in annot_types:
res_df = sa.consensus(
self.PROJECT_NAME, folder_names, annot_type=annot_type
)
# test content of projectName column
assert sorted(res_df["folderName"].unique()) == folder_names

# test structure of resulting DataFrame
assert sorted(res_df.columns) == sorted(df_column_names)
# test structure of resulting DataFrame
assert sorted(res_df.columns) == sorted(df_column_names)

# test lower bound of the score
assert (res_df["score"] >= 0).all()
# test lower bound of the score
assert (res_df["score"] >= 0).all()

# test upper bound of the score
assert (res_df["score"] <= 1).all()
# test upper bound of the score
assert (res_df["score"] <= 1).all()

image_names = [
"bonn_000000_000019_leftImg8bit.png",
"bielefeld_000000_000321_leftImg8bit.png",
]
image_names = [
"bonn_000000_000019_leftImg8bit.png",
"bielefeld_000000_000321_leftImg8bit.png",
]

# test filtering images with given image names list
res_images = sa.consensus(
self.PROJECT_NAME,
folder_names,
export_root=export_path,
image_list=image_names,
)
# test filtering images with given image names list
res_images = sa.consensus(
self.PROJECT_NAME,
folder_names,
export_root=temp_export_path,
image_list=image_names,
)

assert sorted(res_images["imageName"].unique()) == sorted(image_names)
assert sorted(res_images["imageName"].unique()) == sorted(image_names)
99 changes: 51 additions & 48 deletions tests/integration/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,64 +43,67 @@ def test_benchmark(self):
"folderName",
"score",
]
export_path = self.export_path
for i in range(1, 4):
sa.create_folder(self.PROJECT_NAME, self.CONSENSUS_PREFIX + str(i))
sa.create_annotation_classes_from_classes_json(
self.PROJECT_NAME, self.export_path + "/classes/classes.json"
)
sa.upload_images_from_folder_to_project(
self.PROJECT_NAME,
self.export_path + "/images",
annotation_status="Completed",
)
for i in range(1, 4):

with tempfile.TemporaryDirectory() as tmpdir:
temp_export_path = str(tmpdir)

for i in range(1, 4):
sa.create_folder(self.PROJECT_NAME, self.CONSENSUS_PREFIX + str(i))
sa.create_annotation_classes_from_classes_json(
self.PROJECT_NAME, self.export_path + "/classes/classes.json"
)
sa.upload_images_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.PROJECT_NAME,
self.export_path + "/images",
annotation_status="Completed",
)
time.sleep(2)
sa.upload_annotations_from_folder_to_project(
self.PROJECT_NAME, self.export_path
)
for i in range(1, 4):
for i in range(1, 4):
sa.upload_images_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.export_path + "/images",
annotation_status="Completed",
)
time.sleep(2)
sa.upload_annotations_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.export_path + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.PROJECT_NAME, self.export_path
)
for i in range(1, 4):
sa.upload_annotations_from_folder_to_project(
self.PROJECT_NAME + f"/{self.CONSENSUS_PREFIX}" + str(i),
self.export_path + f"/{self.CONSENSUS_PREFIX}" + str(i),
)

for annotation_type in annotation_types:
res_df = sa.benchmark(
self.PROJECT_NAME,
self.GT_FOLDER_NAME,
folder_names,
annot_type=annotation_type,
)
# test content of projectName column
assert sorted(res_df["folderName"].unique()) == folder_names
for annotation_type in annotation_types:
res_df = sa.benchmark(
self.PROJECT_NAME,
self.GT_FOLDER_NAME,
folder_names,
annot_type=annotation_type,
)
# test content of projectName column
assert sorted(res_df["folderName"].unique()) == folder_names

# test structure of resulting DataFrame
assert sorted(res_df.columns) == sorted(df_column_names)
# test structure of resulting DataFrame
assert sorted(res_df.columns) == sorted(df_column_names)

# test lower bound of the score
assert (res_df["score"] >= 0).all()
# test lower bound of the score
assert (res_df["score"] >= 0).all()

# test upper bound of the score
assert (res_df["score"] <= 1).all()
# test upper bound of the score
assert (res_df["score"] <= 1).all()

image_names = [
"bonn_000000_000019_leftImg8bit.png",
"bielefeld_000000_000321_leftImg8bit.png",
]
image_names = [
"bonn_000000_000019_leftImg8bit.png",
"bielefeld_000000_000321_leftImg8bit.png",
]

# test filtering images with given image names list
res_images = sa.benchmark(
self.PROJECT_NAME,
self.GT_FOLDER_NAME,
folder_names,
export_root=export_path,
image_list=image_names,
)
# test filtering images with given image names list
res_images = sa.benchmark(
self.PROJECT_NAME,
self.GT_FOLDER_NAME,
folder_names,
export_root=temp_export_path,
image_list=image_names,
)

assert sorted(res_images["imageName"].unique()) == sorted(image_names)
assert sorted(res_images["imageName"].unique()) == sorted(image_names)