Perform Multi-class Image Classification

A variation of the single-class classification task is the multi-class classification task, i.e., where a sample belongs to multiple classes at the same time. In other words, every input can have an arbitrary amount of output labels (zero, one or more).

To run an example, first get the appropriate dataset:

python util/data/get_a_dataset.py --dataset miml --output-folder toy_dataset

and then run the task with the command:

python template/RunMe.py --dataset-folder toy_dataset/MIML --runner-class multi_label_image_classification --criterion-name BCEWithLogitsLoss

The dataset is expected to be in the following structure, where dataset_folder has to point to the root of the three folders train/val/test.

Example of dataset structure:

dataset_folder = "./datasets/dataset_folder"

which contains the sub-folders for each split as follows:

'dataset_folder'/train
'dataset_folder'/val
'dataset_folder'/test

Each of the three splits (train, val, test) should contain a folder called images containing all of the images (the file names of the images can be arbitrary). The split folder (so one in train, one in val and one in test) should also contain a csv file called labels.csv formatted so:

filename,class_0,class_1,...,class_n
images/img_1.png,1,-1,-1,...,1

where the filename is the relative path to the image file from the split folder and 1/-1 to indicate presence/absence of a particular label.

Example:

train/image/whatever.png
train/image/you.png
train/image/like.png
train/labels.csv

and the labels.csv should contain:

filename,cat,dog,elephant
image/whatever.png,1,1,-1
image/you.png,1,-1,-1
image/like.png,-1,1,1