Skip to content

Commit

Permalink
[DAR-2239][External] Added missing argument for call of get_image_pat…
Browse files Browse the repository at this point in the history
…h_from_stream() (#847)

* Added missing argument for call of get_image_path_from_stream()

* Fix typo

* Corrected docstring
  • Loading branch information
JBWilkie authored May 22, 2024
1 parent 979aebb commit 19bc2a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion darwin/dataset/local_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _setup_annotations_and_images(
annotation_filepath = Path(annotation_filepath)
darwin_json = stream_darwin_json(annotation_filepath)
image_path = get_image_path_from_stream(
darwin_json, images_dir, with_folders, annotation_filepath
darwin_json, images_dir, annotation_filepath, with_folders
)
if image_path.exists():
if not keep_empty_annotations and is_stream_list_empty(
Expand Down
6 changes: 4 additions & 2 deletions darwin/dataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,10 @@ def _map_annotations_to_images(
annotations_paths = []
invalid_annotation_paths = []
for annotation_path in get_annotation_files_from_dir(annotations_dir):
darwin_json = stream_darwin_json(annotation_path)
image_path = get_image_path_from_stream(darwin_json, images_dir)
darwin_json = stream_darwin_json(Path(annotation_path))
image_path = get_image_path_from_stream(
darwin_json, images_dir, Path(annotation_path)
)
if image_path.exists():
images_paths.append(image_path)
annotations_paths.append(annotation_path)
Expand Down
4 changes: 3 additions & 1 deletion darwin/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ def stream_darwin_json(path: Path) -> PersistentStreamingJSONObject:
def get_image_path_from_stream(
darwin_json: PersistentStreamingJSONObject,
images_dir: Path,
with_folders: bool,
annotation_filepath: Path,
with_folders: bool = True,
) -> Path:
"""
Returns the path to the image file associated with the given darwin json file.
Expand All @@ -447,6 +447,8 @@ def get_image_path_from_stream(
Path to the directory containing the images.
with_folders: bool
Flag to determine if the release was pulled with or without folders.
annotation_filepath : Path
Path to the annotation file. Used if loading the JSON as a stream fails.
Returns
-------
Expand Down

0 comments on commit 19bc2a4

Please sign in to comment.