Project_labelling class

Phenopype labelling projects are compact versions of regular phenopype projects, suitable for rapid labelling of images using a key-map. After creating a labelling project, the data folder contains images, labels, and backup-files; the export folder contains the exported csv-files.

import phenopype as pp

proj = pp.Project_labelling(root_dir=r"my_labelling_project")
proj.add_files(r"my-data", recursive=True)"v1", config_path=r"templates\template_labelling1.yaml", label_position=(0.1,0.1), skip=False)
proj.export(tag="v1", overwrite=True, category_column=True)

## after closing Python, the project can be accessed by simply using Project class again:
proj = pp.Project_labelling(root_dir=r"labelling_test")

Above code creates a folder structure as follows:

class phenopype.main.Project_labelling(root_dir, load=True, check=False, overwrite=False, ask=True, **kwargs)

Bases: object

add_files(images, filetypes=['jpg', 'JPG', 'jpeg', 'JPEG', 'tif', 'png', 'bmp'], include=[], include_all=True, exclude=[], n_max=None, recursive=False, overwrite=False, unique='path', **kwargs)

Add files to the labeling tool.

  • images (str or list) – Either a directory containing images or a list of image paths.

  • filetypes (list, optional) – List of file extensions to include. Default is _vars.default_filetypes.

  • include (list, optional) – List of patterns to include. Default is [].

  • include_all (bool, optional) – Whether to include all patterns in include. Default is True.

  • exclude (list, optional) – List of patterns to exclude. Default is [].

  • n_max (int, optional) – Maximum number of files to add. Default is None (add all files).

  • recursive (bool, optional) – Whether to search directories recursively. Default is False.

  • overwrite (bool, optional) – Whether to overwrite existing files. Default is False.

  • unique (str, optional) – Strategy to handle duplicate files. Default is “path”.

  • **kwargs (dict) – Additional keyword arguments.

Return type:


run(tag, config_path, index=False, autosave=60, skip=False, overwrite=False, image_path='abs', **kwargs)

Run the labeling tool to process images using to the specified configuration.

  • tag (str) – A tag for the labeling operation.

  • config_path (str) – Path to the configuration file.

  • overwrite (bool, optional) – Whether to overwrite existing labels. Default is False.

  • image_path (str, optional) – Type of image path to use. Default is “abs”.

  • **kwargs (dict) – Additional keyword arguments.

Return type:



This method initializes the labeling process by setting up necessary attributes, loading labels if they exist, and navigating through images based on the provided configuration. It iterates through each step defined in the configuration and processes images accordingly. The labeling process continues until the user exits by pressing the escape key.

export(tag, overwrite=False, save_dir=None, **kwargs)

Export labels DataFrame to a specified directory as a CSV file.

  • tag (str) – A tag for the export operation.

  • category_column (bool, optional) – Whether to use the ‘category’ column or make it its own column. Default is False.

  • overwrite (bool, optional) – Whether to overwrite existing files. Default is False.

  • save_dir (str, optional) – Directory to save the CSV file. Defaults to self.root_dir if not provided.

  • **kwargs (dict) – Additional keyword arguments. Unused in this method.

Return type: