Single-label image classification / cheat sheet

Target audience: Data scientists and developers

Problem formulation

Use this cheat sheet:
If your input data consists of labeled images containing exactly one of multiple classes. This is called single-label classification.

Example use cases

SkinLiasonMalignant BenignPA3

Images of skin lesions that are either benign or malignant.
(image source)

Cracks in solar panel PA4

Images of solar panels that are either defective or functional.
(image source)

MNIST tagged 8 5 PA2

Images that contain exactly one handwritten number from 0 to 9.
(image source)

Data preparation

Data input requirements

Prepare a zip file with a folder containing all your images and a corresponding index.csv.
The Peltarion Platform supports .jpg or .png.

index csv PA1

Structure of index.csv

You need to structure the data so that each image is labeled with one class in the index.csv file.

image class


class 1


class 2

Use same sized images

All of your images need to be the same size. If they are different sizes, you will need to resize them before creating the zip file, e.g., by using the Pillow package with this script.

Most of the best-performing deep learning models for images were constructed based on images sized 256x256 or 224x224. If your images are bigger than that, we recommend resizing your images to around this size to maximize the likelihood of getting good performance on your data.

Change preprocessing in the Datasets view

Once uploaded to the platform, choose Preprocessing as No pre-processing for the image column, and One-hot encoding for the class column.

Features Single label image classification PA1


Snippets are pre-built neural network architectures available on the platform. Several are good for image classification.

Image size Recommended snippet

Between 10x10 and 96x96 pixels

ResNetV2 Small

Between 96x96 and 320x320 pixels

ResNetV2 Large

Above 320x320 pixels

We recommend you to resize them to max 320x320.

Try the smallest depth model first

Try the smallest depth model first, since it will be faster to train and may already be complex enough to model your data well.

If the results are not good enough, you can move toward increasingly deep models in later experiments.

The second number next to the snippet name represents the depth of the model; the deeper the model, the more complex it is.

Changes in the Modeling view

On the last Dense block change the number of nodes to the number of classes in your data, and set the Activation to Softmax. In this instance, we set softmax because it models the fact that labels are mutually exclusive (one and only one of them is right).

On the Target block, make sure the loss function is Categorical crossentropy.

Last blocks Single label image classification PA1
Get started for free