peal.web.ingest.build_pair_dataset

peal.web.ingest.build_pair_dataset(class_root, classes, class_a, class_b, out_dir, max_per_class=None, link=True)[source]

Write the binary imgs/<0|1> + data.csv layout for two classes.

class_a becomes label 0 and class_b label 1. Images are renamed to <label>/<index:06d><ext> and data.csv gets the header ImgPath,Class. Symlinks are used by default (the extracted upload stays the owner of the bytes); link=False copies.

Parameters:
  • class_root (str) – Directory returned by discover_classes.

  • classes (dict) – {class_name: [relative image paths]} from discover_classes.

  • class_a (str) – The two class folders to use; must differ and exist in classes.

  • class_b (str) – The two class folders to use; must differ and exist in classes.

  • out_dir (str) – Dataset root that receives imgs/ and data.csv.

  • max_per_class (int, optional) – Truncate each class to its first max_per_class images.

  • link (bool) – Symlink (True) or copy (False) the images.

Returns:

{class_name: number of images used} for the two classes.

Return type:

dict

Raises:

IngestError – If the classes are equal or unknown.