Skip to content

Parser

[source]

Parser

icevision.parsers.Parser(template_record, class_map=None, idmap=None)

Base class for all parsers, implements the main parsing logic.

The actual fields to be parsed are defined by the mixins used when defining a custom parser. The only required fields for all parsers are image_id and image_width_height.

Arguments

  • idmap Optional[icevision.core.id_map.IDMap]: Maps from filenames to unique ids, pass an IDMap() if you need this information.

Examples

Create a parser for image filepaths.

class FilepathParser(Parser, FilepathParserMixin):
    # implement required abstract methods


[source]

parse

Parser.parse(data_splitter=None, autofix=True, show_pbar=True, cache_filepath=None)

Loops through all data points parsing the required fields.

Arguments

  • data_splitter icevision.data.DataSplitter: How to split the parsed data, defaults to a [0.8, 0.2] random split.
  • show_pbar bool: Whether or not to show a progress bar while parsing the data.
  • cache_filepath Union[str, pathlib.Path]: Path to save records in pickle format. Defaults to None, e.g. if the user does not specify a path, no saving nor loading happens.

Returns

A list of records for each split defined by data_splitter.