import_pickles¶
-
menpo.io.import_pickles(pattern, max_pickles=None, shuffle=False, as_generator=False, verbose=False, **kwargs)[source]¶ Multiple pickle importer.
Menpo unambiguously uses
.pklas it’s choice of extension for Pickle files. Menpo also supports automatic importing and exporting of gzip compressed pickle files - just choose afilepathendingpkl.gzand gzip compression will automatically be applied. Compression can massively reduce the filesize of a pickle file at the cost of longer import and export times.Note that this is a function returns a
LazyList. Therefore, the function will return immediately and indexing into the returned list will load a pickle at run time. If all pickles should be loaded, then simply wrap the returnedLazyListin a Python list.- Parameters
pattern (str) – A glob path pattern to search for pickles. Every pickle found to match the glob will be imported one by one. See
pickle_pathsfor more details of what pickles will be found.max_pickles (positive int, optional) – If not
None, only import the firstmax_picklesfound. Else, import all.shuffle (bool, optional) – If
True, the order of the returned pickles will be randomised. IfFalse, the order of the returned pickles will be alphanumerically ordered.as_generator (bool, optional) – If
True, the function returns a generator and assets will be yielded one after another when the generator is iterated over.verbose (bool, optional) – If
Trueprogress of the importing will be dynamically reported with a progress bar.
- Returns
lazy_list (
LazyListor generator of Python objects) – ALazyListor generator yielding whatever Python objects are present in the Pickle file instances that match the glob pattern provided.- Raises
ValueError – If no pickles are found at the provided glob.