[Python] How to create a pairs. csv file given an image dataset

Discussão em 'Python' iniciado por Stack, Setembro 7, 2025.

  1. Stack

    Stack Membro Participativo

    Given a dataset of images, I would like to create a pairs.csv file for both train and test set. The format for the csv file is shown below

    Let's assume in train set folder A contains the following images:

    1.jpg
    2.jpg
    3.jpg


    then my CSV file will look like

    |ImgA|ImgB
    |1.jpg|2.jpg
    |1.jpg|3.jpg
    |2.jpg|1.jpg
    |2.jpg|3.jpg
    |3.jpg|1.jpg
    |3.jpg|2.jpg


    Another example of the dataset and csv file structure is shown below.

    For the folder structure shown here

    [​IMG]

    some of the csv file entries are as follows:

    [​IMG]

    I could do it manually if the number of images and permutations involved were not that large. For example, the screenshots were taken from a folder which has 31 subdirectories each subdirectory contains at most 5 or 6 images similar to screenshot 2.

    Continue reading...

Compartilhe esta Página