From 23a0d1db95af5de33f8f4a611f95f1dcd8a67c3c Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 2 Jan 2024 14:12:23 -0500 Subject: [PATCH] adding progress flag to draw_labels() --- fiftyone/core/collections.py | 6 ++++++ fiftyone/utils/annotations.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fiftyone/core/collections.py b/fiftyone/core/collections.py index 68dae5003e..19a1d14eb9 100644 --- a/fiftyone/core/collections.py +++ b/fiftyone/core/collections.py @@ -8188,6 +8188,7 @@ def draw_labels( label_fields=None, overwrite=False, config=None, + progress=None, **kwargs, ): """Renders annotated versions of the media in the collection with the @@ -8217,6 +8218,9 @@ def draw_labels( config (None): an optional :class:`fiftyone.utils.annotations.DrawConfig` configuring how to draw the labels + progress (None): whether to render a progress bar (True/False), use + the default value ``fiftyone.config.show_progress_bars`` + (None), or a progress callback function to invoke instead **kwargs: optional keyword arguments specifying parameters of the default :class:`fiftyone.utils.annotations.DrawConfig` to override @@ -8244,6 +8248,7 @@ def draw_labels( rel_dir=rel_dir, label_fields=label_fields, config=config, + progress=progress, **kwargs, ) @@ -8254,6 +8259,7 @@ def draw_labels( rel_dir=rel_dir, label_fields=label_fields, config=config, + progress=progress, **kwargs, ) diff --git a/fiftyone/utils/annotations.py b/fiftyone/utils/annotations.py index f8344b288d..66c5c9a0e2 100644 --- a/fiftyone/utils/annotations.py +++ b/fiftyone/utils/annotations.py @@ -2404,7 +2404,13 @@ def draw_labeled_image( def draw_labeled_videos( - samples, output_dir, rel_dir=None, label_fields=None, config=None, **kwargs + samples, + output_dir, + rel_dir=None, + label_fields=None, + config=None, + progress=None, + **kwargs, ): """Renders annotated versions of the videos in the collection with the specified label data overlaid to the given directory. @@ -2429,6 +2435,9 @@ def draw_labeled_videos( If omitted, all compatiable fields are rendered config (None): an optional :class:`DrawConfig` configuring how to draw the labels + progress (None): whether to render a progress bar (True/False), use the + default value ``fiftyone.config.show_progress_bars`` (None), or a + progress callback function to invoke instead **kwargs: optional keyword arguments specifying parameters of the default :class:`DrawConfig` to override @@ -2448,7 +2457,7 @@ def draw_labeled_videos( num_videos = len(samples) outpaths = [] - for idx, sample in enumerate(samples, 1): + for idx, sample in enumerate(samples.iter_samples(progress=progress), 1): if is_clips: logger.info("Drawing labels for clip %d/%d", idx, num_videos) base, ext = os.path.splitext(sample.filepath)