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

allow flexibility to provide absolute path to annotations #1840

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
):
"""
:param data_dir: Where the data is stored.
:param json_annotation_file: Name of the coco json file. Path relative to data_dir.
:param json_annotation_file: Name of the coco json file. Path can be either absolute, or relative to data_dir.
:param images_dir: Name of the directory that includes all the images. Path relative to data_dir.
:param with_crowd: Add the crowd groundtruths to __getitem__
:param class_ids_to_ignore: List of class ids to ignore in the dataset. By default, doesnt ignore any class.
Expand Down Expand Up @@ -82,7 +82,10 @@ def _setup_data_source(self) -> int:
Parse COCO annotation file
:return: Number of images in annotation JSON
"""
annotation_file_path = os.path.join(self.data_dir, self.json_annotation_file)
if os.path.isabs(self.json_annotation_file):
annotation_file_path = self.json_annotation_file
else:
annotation_file_path = os.path.join(self.data_dir, self.json_annotation_file)
if not os.path.exists(annotation_file_path):
raise ValueError("Could not find annotation file under " + str(annotation_file_path))

Expand Down
Loading