Skip to main content
Version: v1.4.0

Dataset format: Image classification

Dataset format

The data for an image classification experiment needs a zip file (1) containing a CSV file (2) and an image folder (3).

folder_name.zip (1)
│ └───csv_name.csv (2)
│ │
│ └───image_folder_name (3)
│ └───name_of_image.image_extension
│ └───name_of_image.image_extension
│ └───name_of_image.image_extension
│ ...
Note

You can have multiple CSV files in the zip file that you can use as train, validation, and test dataframes:

  • A train CSV file needs to follow the format described above
  • A validation CSV file needs to follow the same format as a train CSV file
  • A test CSV file needs to follow the same format as a train CSV file, but does not require a label column(s)
  1. The available dataset connectors require the data for an image classification experiment to be in a zip file.
    Note

    To learn how to upload your zip file as your dataset in H2O Hydrogen Torch, see Dataset connectors.

  2. A CSV file containing the following columns:
    • An image column containing the names of the images for the experiment, where each image has an image extension specified
      Note
      • Images can contain a mix of supported image extensions. To learn about supported image extensions, see Supported image extensions for image processing.
      • The names of the image files do not specify the data directory (location of the images in the zip file). You can specify the data directory (data folder) when uploading the dataset or before the dataset is used for an experiment. For more information, see Import dataset settings.
    • One or more label columns containing either one-hot encoded multi-class labels or multiple multi-class/multi-label labels. For multi-class and binary classification, a single label column is sufficient
      Note
      • H2O Hydrogen Torch can solve both multi-class and multi-label classification problems. In multi-class problems, the classes are mutually exclusive, while the classes represent unique labels for multi-label problems. For N label class columns, in multi-class problems, only a single column could be set to 1, while in multi-label problems, all or none could be set to 1.
      • For binary classification experiments utilizing precison, recall, F1, F05, or F2 as a metric, the label column needs to contain 0/1 values. If the column contains string values, the column is transformed into multiple columns using a one-hot encoder method resulting in the experiment being treated as a multi-class classification experiment while leading to an incorrect calculation of the precision, recall, F1, F05, or F2 metric.
    • An optional fold column containing cross-validation fold indexes
      Note

      The fold column can include integers (0, 1, 2, … , N-1 values or 1, 2, 3… , N values) or categorical values.

  3. An image folder that contains all the images specified in the image column; H2O Hydrogen Torch uses the images in this folder to run the image classification experiment.
    Note

    All image file names need to specify image extension. Images can contain a mix of supported image extensions. To learn about supported image extensions, see Supported image extensions for image processing.

Example

The flower_image_classification.zip file is a preprocessed dataset in H2O Hydrogen Torch and was formatted to solve a multi-class image classification problem. The structure of the zip file is as follows:

flower_image_classification.zip
│ └───train.csv
│ │
│ └───images
│ └───100080576_f52e8ee070_n.jpg
│ └───10043234166_e6dd915111_n.jpg
│ └───1008566138_6927679c8a.jpg
│ ...

The first three rows of the train.csv file are as follows:

imagelabel
5777669976_a205f61e5b.jpgroses
27466794_57e4fe5656.jpgsunflowers
15207766_fc2f1d692c_n.jpgdaisy
Note
  • In this example, the data directory in the image column is not specified. Therefore, it needs to be specified when uploading the dataset, and the images folder needs to be specfied as the value for the Data folder setting. For more information, see Import dataset settings.
  • To learn how to access one of the preprocessed datasets in H2O Hydrogen Torch, see Demo (preprocessed) datasets.

Feedback