Docs /Templates/ sinapsis-data-readers

FolderImageDatasetCV2

sinapsis-data-readerscommunitycocokeypointsimagedetection

Python template · sinapsis_data_readers.templates.image_readers.image_folder_reader_cv2

Overview

Dataset creation for images in a directory in the disk with opencv

Methods: - _create_data_entries : Creates the data entries based in the path and name of the image.

- _read_entry : Reads the content of the folder defined in the data directory and returns the content.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-data-readers==1.0.0
uv pip install sinapsis-data-readers==1.0.0
uv add sinapsis-data-readers==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

pattern
str
Optional
Default: "**/*"
data_dirRequired
root path to the data pattern (str) = "**/*": regex to be used with Path.glob. By default, we find recursively. batch_size (int) = 1: if batch size is set to a number >= len(self.data_collection), or batch_size ==-1,… Read full field description

root path to the data pattern (str) = "**/*": regex to be used with Path.glob. By default, we find recursively. batch_size (int) = 1: if batch size is set to a number >= len(self.data_collection), or batch_size ==-1, the entire set of data will be returned at once. shuffle_data (bool) = False: flag to indicate whether to shuffle the list of datafiles. samples_to_load (int) = -1: by default, load all the data unless samples_to_load is set to >= 0. If 0, the list of data files will be empty and no data will be loaded.

str
Required
Default: null
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
root_dir
str | None
Optional
Default: null
batch_size
int
Optional
Default: 1
load_on_init

bool = False flag to indicate if data should be loaded in the __init__ or during execution. Note that for large data sets with large files, it is recommended to set this flag to false in order to avoid long initialization times of the template.

bool
Optional
Default: false
shuffle_data
bool
Optional
Default: false
is_ground_truth

bool = False weather the data is a ground truth or not.

bool
Optional
Default: false
samples_to_load
int
Optional
Default: -1
label_path_index

int = -2 for datasets that rely on the dirname as the ground truth. The image file path will be split as 'data_label = data_file_path.ext.split(os.sep)[label_path_index]'.

int
Optional
Default: -2

Configuration example

Example from the Python docstring:

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: FolderImageDatasetCV2
  class_name: FolderImageDatasetCV2
  template_input: InputTemplate
  attributes:
    data_dir: '/path/to/data/dit'
    pattern: '**/*'
    batch_size: 1
    shuffle_data: false
    samples_to_load: -1
    load_on_init: false
    label_path_index: -2
    is_ground_truth: false
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "FolderImageDatasetCV2"
    class_name: "FolderImageDatasetCV2"
    attributes:
      pattern: "**/*"
      data_dir: "<required>"
      root_dir: null
      batch_size: 1
      load_on_init: false
      shuffle_data: false
      is_ground_truth: false
      samples_to_load: -1
      label_path_index: -2

Inheritance

Immediate parent: sinapsis_data_readers.templates.image_readers.base_image_folder_data_loader.ImageBaseDataReader

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.