core/data/image_folder_dataset library

Image-folder classification / triplet dataset.

Mirrors the ImageNet-style directory layout:

<root>/
  <class_0>/  *.jpg | *.jpeg | *.png
  <class_1>/  *.jpg | *.jpeg | *.png
  ...

Every file is decoded once with package:image, resized to imageSize × imageSize, normalized to [0, 1] (channels-last RGB), and cached in RAM as a Float32List.

Each dataset item is a FaceSample:

patches: Tensor [numPatches, patchSize*patchSize*3]
label:   int in [0, numClasses)

The patchification layout matches ViTBackbone: patches iterated row-major over the image, with each patch's patchSize × patchSize × 3 pixels flattened (dy, dx, c).

  • sampleTriplet — draws (anchor, positive, negative) with anchor & positive from the same class and negative from a different class, all patchified as Tensors on the requested device. Perfect for face-recognition / metric-learning training.

  • Train / val split is deterministic given a seed.

Classes

FaceSample
One example from an ImageFolderDataset: a patchified image plus its integer class label.
ImageFolderDataset
TripletSample
Bundle of three patchified images used by triplet-loss metric learning (anchor + positive from the same class, negative from a different class).