Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLA-683][external] 2 Minor fixes for importing of PASCAL VOC annotations #783

Merged
merged 4 commits into from Mar 7, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion darwin/cli_functions.py
Expand Up @@ -881,7 +881,7 @@ def dataset_import(
import_reviewers : bool, default: False
If ``True`` it will import the reviewers from the files to the dataset, if .
If ``False`` it will not import the reviewers.
use_multi_cpu : bool, default: True
use_multi_cpu : bool, default: False
If ``True`` it will use all multiple CPUs to speed up the import process.
cpu_limit : Optional[int], default: Core count - 2
The maximum number of CPUs to use for the import process.
Expand Down
5 changes: 4 additions & 1 deletion darwin/importer/formats/pascal_voc.py
Expand Up @@ -3,6 +3,7 @@
from typing import List, Optional

import darwin.datatypes as dt
from darwin.path_utils import deconstruct_full_path


def parse_path(path: Path) -> Optional[dt.AnnotationFile]:
Expand Down Expand Up @@ -57,8 +58,10 @@ def parse_path(path: Path) -> Optional[dt.AnnotationFile]:
)
annotation_classes = {annotation.annotation_class for annotation in annotations}

remote_path, filename = deconstruct_full_path(filename)

return dt.AnnotationFile(
path, filename, annotation_classes, annotations, remote_path="/"
path, filename, annotation_classes, annotations, remote_path=remote_path
)


Expand Down
2 changes: 1 addition & 1 deletion darwin/importer/importer.py
Expand Up @@ -221,7 +221,7 @@ def get_remote_files(
for i in range(0, len(filenames), chunk_size):
chunk = filenames[i : i + chunk_size]
for remote_file in dataset.fetch_remote_files(
{"types": "image,playback_video,video_frame", "filenames": chunk}
{"types": "image,playback_video,video_frame", "item_names": chunk}
):
slot_name = _get_slot_name(remote_file)
remote_files[remote_file.full_path] = (remote_file.id, slot_name)
Expand Down
14 changes: 14 additions & 0 deletions tests/darwin/importer/formats/import_pascalvoc_test.py
Expand Up @@ -171,3 +171,17 @@ def test_returns_annotation_file_with_correct_annotations_with_float_values(
assert annotation.subs == []

assert annotation_file.remote_path == "/"

def test_deconstructs_filepath_properly_if_folder_included_in_filename(
self, annotation_path: Path
):
annotation_path.write_text(
"<root><filename>folder/image.jpg</filename><object><name>Class</name><bndbox><xmin>10</xmin><xmax>10</xmax><ymin>10</ymin><ymax>10</ymax></bndbox></object></root>"
)

annotation_file = parse_path(annotation_path)

assert annotation_file is not None
assert annotation_file.path == annotation_path
assert annotation_file.filename == "image.jpg"
assert annotation_file.remote_path == "/folder"