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

Add first_n argument #151

Merged
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion pyodi/apps/paint_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def paint_annotations(
color_key: str = "category_id",
show_label: bool = True,
filter_crowd: bool = True,
first_n: int = None,
daavoo marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
"""Paint `ground_truth_file` or `predictions_file` annotations on `image_folder` images.

Expand All @@ -59,6 +60,8 @@ def paint_annotations(
color_key: Choose the key in annotations on which the color will depend. Defaults to 'category_id'.
show_label: Choose whether to show label and score threshold on image. Default True.
filter_crowd: Filter out crowd annotations or not. Default True.
first_n: Paint only first n annotations and stop after that.
If None, all images will be painted.
"""
Path(output_folder).mkdir(exist_ok=True, parents=True)

Expand All @@ -85,8 +88,9 @@ def paint_annotations(
image_id_to_annotations[annotation["image_id"]].append(annotation)

image_data = ground_truth["images"]
first_n = first_n or len(image_data)

for image in image_data:
for image in image_data[:first_n]:

image_filename = image["file_name"]
image_id = image["id"]
Expand Down