class documentation

Class for iterating over the elements of an iterable with a static batch size.

This class is often used in conjunction with a ProgressBar to keep the user appraised on the status of a long-running task.

Example usage:

import fiftyone.core.utils as fou

elements = range(int(1e7))

batcher = fou.StaticBatcher(elements, batch_size=10000)

for batch in batcher:
    print("batch size: %d" % len(batch))

batcher = fou.StaticBatcher(elements, batch_size=10000, progress=True)

with batcher:
    for batch in batcher:
        print("batch size: %d" % len(batch))
Parameters
iterablean iterable to batch over. If None, the result of next() will be a batch size instead of a batch, and is an infinite iterator.
batch_sizesize of batches to generate
return_viewswhether to return each batch as a fiftyone.core.view.DatasetView. Only applicable when the iterable is a fiftyone.core.collections.SampleCollection
progresswhether to render a progress bar tracking the consumption of the batches (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead
totalthe length of iterable. Only applicable when progress=True. If not provided, it is computed via len(iterable), if possible
Method __init__ Undocumented
Instance Variable batch_size Undocumented
Method _compute_batch_size Return next batch size. Concrete classes must implement.

Inherited from Batcher:

Method __enter__ Undocumented
Method __exit__ Undocumented
Method __iter__ Undocumented
Method __next__ Undocumented
Method apply_backpressure Apply backpressure needed to rightsize the next batch.
Class Variable manual_backpressure Undocumented
Instance Variable iterable Undocumented
Instance Variable _in_context Undocumented
Instance Variable _iter Undocumented
Instance Variable _last_batch_size Undocumented
Instance Variable _last_offset Undocumented
Instance Variable _manually_applied_backpressure Undocumented
Instance Variable _num_samples Undocumented
Instance Variable _pb Undocumented
Instance Variable _render_progress Undocumented
def __init__(self, iterable, batch_size, return_views=False, progress=False, total=None): (source)

Undocumented

batch_size = (source)

Undocumented

def _compute_batch_size(self): (source)

Return next batch size. Concrete classes must implement.