AutoTrain documentation

Image Classification

You are viewing v0.7.83 version. A newer version v0.7.94 is available.
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Image Classification

Image classification is a form of supervised learning where a model is trained to identify and categorize objects within images. AutoTrain simplifies the process, enabling you to train a state-of-the-art image classification model by simply uploading labeled example images.

Preparing your data

To ensure your image classification model trains effectively, follow these guidelines for preparing your data:

Organizing Images

Prepare a zip file containing your categorized images. Each category should have its own subfolder named after the class it represents. For example, to differentiate between β€˜cats’ and β€˜dogs’, your zip file structure should resemble the following:

cats_and_dogs.zip
β”œβ”€β”€ cats
β”‚   β”œβ”€β”€ cat.1.jpg
β”‚   β”œβ”€β”€ cat.2.jpg
β”‚   β”œβ”€β”€ cat.3.jpg
β”‚   └── ...
└── dogs
    β”œβ”€β”€ dog.1.jpg
    β”œβ”€β”€ dog.2.jpg
    β”œβ”€β”€ dog.3.jpg
    └── ...

Image Requirements

  • Format: Ensure all images are in JPEG, JPG, or PNG format.

  • Quantity: Include at least 5 images per class to provide the model with sufficient examples for learning.

  • Exclusivity: The zip file should exclusively contain folders named after the classes, and these folders should only contain relevant images. No additional files or nested folders should be included.

Additional Tips

  • Uniformity: While not required, having images of similar sizes and resolutions can help improve model performance.

  • Variability: Include a variety of images for each class to encompass the range of appearances and contexts the model might encounter in real-world scenarios.

Some points to keep in mind:

  • The zip file should contain multiple folders (the classes), each folder should contain images of a single class.
  • The name of the folder should be the name of the class.
  • The images must be jpeg, jpg or png.
  • There should be at least 5 images per class.
  • There must not be any other files in the zip file.
  • There must not be any other folders inside the zip folder.

When train.zip is decompressed, it creates two folders: cats and dogs. these are the two categories for classification. The images for both categories are in their respective folders. You can have as many categories as you want.

< > Update on GitHub