Skip to content

Commit

Permalink
more progress flags
Browse files Browse the repository at this point in the history
  • Loading branch information
brimoor committed Dec 30, 2023
1 parent 74219a7 commit d4adb2c
Show file tree
Hide file tree
Showing 30 changed files with 618 additions and 295 deletions.
42 changes: 34 additions & 8 deletions fiftyone/core/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,12 +826,11 @@ def view(self):
"""
raise NotImplementedError("Subclass must implement view()")

def iter_samples(self, progress=None, autosave=False, batch_size=None):
def iter_samples(self, progress=False, autosave=False, batch_size=None):
"""Returns an iterator over the samples in the collection.
Args:
progress (None): whether to render a progress bar tracking the
iterator's progress
progress (False): whether to render a progress bar
autosave (False): whether to automatically save changes to samples
emitted by this iterator
batch_size (None): a batch size to use when autosaving samples. Can
Expand All @@ -847,16 +846,15 @@ def iter_samples(self, progress=None, autosave=False, batch_size=None):
def iter_groups(
self,
group_slices=None,
progress=None,
progress=False,
autosave=False,
batch_size=None,
):
"""Returns an iterator over the groups in the collection.
Args:
group_slices (None): an optional subset of group slices to load
progress (None): whether to render a progress bar tracking the
iterator's progress
progress (False): whether to render a progress bar
autosave (False): whether to automatically save changes to samples
emitted by this iterator
batch_size (None): a batch size to use when autosaving samples. Can
Expand Down Expand Up @@ -2735,6 +2733,7 @@ def compute_metadata(
num_workers=None,
skip_failures=True,
warn_failures=False,
progress=None,
):
"""Populates the ``metadata`` field of all samples in the collection.
Expand All @@ -2748,13 +2747,15 @@ def compute_metadata(
raising an error if metadata cannot be computed for a sample
warn_failures (False): whether to log a warning if metadata cannot
be computed for a sample
progress (None): whether to render a progress bar
"""
fomt.compute_metadata(
self,
overwrite=overwrite,
num_workers=num_workers,
skip_failures=skip_failures,
warn_failures=warn_failures,
progress=progress,
)

def apply_model(
Expand All @@ -2768,6 +2769,7 @@ def apply_model(
skip_failures=True,
output_dir=None,
rel_dir=None,
progress=None,
**kwargs,
):
"""Applies the :class:`FiftyOne model <fiftyone.core.models.Model>` or
Expand Down Expand Up @@ -2816,6 +2818,7 @@ def apply_model(
subdirectories in ``output_dir`` that match the shape of the
input paths. The path is converted to an absolute path (if
necessary) via :func:`fiftyone.core.storage.normalize_path`
progress (None): whether to render a progress bar
**kwargs: optional model-specific keyword arguments passed through
to the underlying inference implementation
"""
Expand All @@ -2830,6 +2833,7 @@ def apply_model(
skip_failures=skip_failures,
output_dir=output_dir,
rel_dir=rel_dir,
progress=progress,
**kwargs,
)

Expand All @@ -2840,6 +2844,7 @@ def compute_embeddings(
batch_size=None,
num_workers=None,
skip_failures=True,
progress=None,
**kwargs,
):
"""Computes embeddings for the samples in the collection using the
Expand Down Expand Up @@ -2879,6 +2884,7 @@ def compute_embeddings(
raising an error if embeddings cannot be generated for a
sample. Only applicable to :class:`fiftyone.core.models.Model`
instances
progress (None): whether to render a progress bar
**kwargs: optional model-specific keyword arguments passed through
to the underlying inference implementation
Expand Down Expand Up @@ -2908,6 +2914,7 @@ def compute_embeddings(
batch_size=batch_size,
num_workers=num_workers,
skip_failures=skip_failures,
progress=progress,
**kwargs,
)

Expand All @@ -2922,6 +2929,7 @@ def compute_patch_embeddings(
batch_size=None,
num_workers=None,
skip_failures=True,
progress=None,
):
"""Computes embeddings for the image patches defined by
``patches_field`` of the samples in the collection using the given
Expand Down Expand Up @@ -2973,6 +2981,7 @@ def compute_patch_embeddings(
applicable for Torch-based models
skip_failures (True): whether to gracefully continue without
raising an error if embeddings cannot be generated for a sample
progress (None): whether to render a progress bar
Returns:
one of the following:
Expand Down Expand Up @@ -3003,6 +3012,7 @@ def compute_patch_embeddings(
alpha=alpha,
handle_missing=handle_missing,
skip_failures=skip_failures,
progress=progress,
)

def evaluate_regressions(
Expand All @@ -3012,6 +3022,7 @@ def evaluate_regressions(
eval_key=None,
missing=None,
method=None,
progress=None,
**kwargs,
):
"""Evaluates the regression predictions in this collection with respect
Expand Down Expand Up @@ -3050,6 +3061,7 @@ def evaluate_regressions(
The supported values are
``fo.evaluation_config.regression_backends.keys()`` and the
default is ``fo.evaluation_config.regression_default_backend``
progress (None): whether to render a progress bar
**kwargs: optional keyword arguments for the constructor of the
:class:`fiftyone.utils.eval.regression.RegressionEvaluationConfig`
being used
Expand All @@ -3064,6 +3076,7 @@ def evaluate_regressions(
eval_key=eval_key,
missing=missing,
method=method,
progress=progress,
**kwargs,
)

Expand All @@ -3075,6 +3088,7 @@ def evaluate_classifications(
classes=None,
missing=None,
method=None,
progress=None,
**kwargs,
):
"""Evaluates the classification predictions in this collection with
Expand Down Expand Up @@ -3122,6 +3136,7 @@ def evaluate_classifications(
The supported values are
``fo.evaluation_config.classification_backends.keys()`` and the
default is ``fo.evaluation_config.classification_default_backend``
progress (None): whether to render a progress bar
**kwargs: optional keyword arguments for the constructor of the
:class:`fiftyone.utils.eval.classification.ClassificationEvaluationConfig`
being used
Expand All @@ -3137,6 +3152,7 @@ def evaluate_classifications(
classes=classes,
missing=missing,
method=method,
progress=progress,
**kwargs,
)

Expand All @@ -3153,6 +3169,7 @@ def evaluate_detections(
use_boxes=False,
classwise=True,
dynamic=True,
progress=None,
**kwargs,
):
"""Evaluates the specified predicted detections in this collection with
Expand Down Expand Up @@ -3245,6 +3262,7 @@ def evaluate_detections(
label (True) or allow matches between classes (False)
dynamic (True): whether to declare the dynamic object-level
attributes that are populated on the dataset's schema
progress (None): whether to render a progress bar
**kwargs: optional keyword arguments for the constructor of the
:class:`fiftyone.utils.eval.detection.DetectionEvaluationConfig`
being used
Expand All @@ -3265,6 +3283,7 @@ def evaluate_detections(
use_boxes=use_boxes,
classwise=classwise,
dynamic=dynamic,
progress=progress,
**kwargs,
)

Expand All @@ -3275,6 +3294,7 @@ def evaluate_segmentations(
eval_key=None,
mask_targets=None,
method=None,
progress=None,
**kwargs,
):
"""Evaluates the specified semantic segmentation masks in this
Expand Down Expand Up @@ -3328,6 +3348,7 @@ class for the purposes of computing evaluation metrics like
The supported values are
``fo.evaluation_config.segmentation_backends.keys()`` and the
default is ``fo.evaluation_config.segmentation_default_backend``
progress (None): whether to render a progress bar
**kwargs: optional keyword arguments for the constructor of the
:class:`fiftyone.utils.eval.segmentation.SegmentationEvaluationConfig`
being used
Expand All @@ -3342,6 +3363,7 @@ class for the purposes of computing evaluation metrics like
eval_key=eval_key,
mask_targets=mask_targets,
method=method,
progress=progress,
**kwargs,
)

Expand Down Expand Up @@ -8234,6 +8256,7 @@ def export(
label_field=None,
frame_labels_field=None,
overwrite=False,
progress=None,
**kwargs,
):
"""Exports the samples in the collection to disk.
Expand Down Expand Up @@ -8407,6 +8430,7 @@ def export(
overwrite (False): whether to delete existing directories before
performing the export (True) or to merge the export with
existing files and directories (False)
progress (None): whether to render a progress bar
**kwargs: optional keyword arguments to pass to the dataset
exporter's constructor. If you are exporting image patches,
this can also contain keyword arguments for
Expand All @@ -8432,6 +8456,7 @@ def export(
label_field=label_field,
frame_labels_field=frame_labels_field,
overwrite=overwrite,
progress=progress,
**kwargs,
)

Expand Down Expand Up @@ -9054,8 +9079,7 @@ def to_dict(
readable format with newlines and indentations. Only applicable
to datasets that contain videos when a ``frame_labels_dir`` is
provided
progress (None): whether to render a progress bar tracking the
iterator's progress of the sample serialization
progress (None): whether to render a progress bar
Returns:
a JSON dict
Expand Down Expand Up @@ -10926,6 +10950,7 @@ def _export(
label_field=None,
frame_labels_field=None,
overwrite=False,
progress=None,
**kwargs,
):
if dataset_type is None and dataset_exporter is None:
Expand Down Expand Up @@ -10997,6 +11022,7 @@ def _export(
dataset_exporter=dataset_exporter,
label_field=label_field,
frame_labels_field=frame_labels_field,
progress=progress,
**kwargs,
)

Expand Down
Loading

0 comments on commit d4adb2c

Please sign in to comment.