---
title: MLImageClassifier
framework: createml
role: symbol
role_heading: Structure
path: createml/mlimageclassifier
---

# MLImageClassifier

A model you train to classify images.

## Declaration

```swift
struct MLImageClassifier
```

## Mentioned in

Creating an Image Classifier Model Improving Your Model’s Accuracy

## Overview

Overview Use an image classifier to train a machine learning model that you can include in your app to categorize images. When you create the model, you give it a training dataset made up of labeled images, along with parameters that control the training process. For example, you can provide the model with images of elephants and giraffes, in two folders labeled Elephant and Giraffe, to train it to recognize these animals. After training completes, you evaluate the trained model by showing it a testing dataset containing labeled images that the model hasn’t seen before. The metrics that come from this evaluation tell you whether the model performs well enough. For example, you can see how often the elephant and giraffe classifier mistakes a giraffe for an elephant. When the model makes too many mistakes, you can add more or better training data, or change the parameters, and try again. When your model does perform well enough, you save it as a Core ML model file with the mlmodel extension. You can then import this model file into an app—like the Classifying Images with Vision and Core ML sample code project—that uses a Core ML model file to classify images.

## Topics

### Training an image classifier asynchronously

- [makeTrainingSession(trainingData:parameters:sessionParameters:)](createml/mlimageclassifier/maketrainingsession(trainingdata:parameters:sessionparameters:).md)
- [train(trainingData:parameters:sessionParameters:)](createml/mlimageclassifier/train(trainingdata:parameters:sessionparameters:).md)
- [resume(_:)](createml/mlimageclassifier/resume(_:).md)
- [restoreTrainingSession(sessionParameters:)](createml/mlimageclassifier/restoretrainingsession(sessionparameters:).md)

### Creating an image classifier from a checkpoint

- [init(checkpoint:)](createml/mlimageclassifier/init(checkpoint:).md)

### Training an image classifier synchronously

- [init(trainingData:parameters:)](createml/mlimageclassifier/init(trainingdata:parameters:).md)

### Evaluating an image classifier

- [evaluation(on:)](createml/mlimageclassifier/evaluation(on:).md)
- [trainingMetrics](createml/mlimageclassifier/trainingmetrics.md)
- [validationMetrics](createml/mlimageclassifier/validationmetrics.md)

### Testing an image classifier

- [prediction(from:)](createml/mlimageclassifier/prediction(from:).md)
- [predictions(from:)](createml/mlimageclassifier/predictions(from:).md)

### Saving an image classifier

- [write(to:metadata:)](createml/mlimageclassifier/write(to:metadata:).md)
- [write(toFile:metadata:)](createml/mlimageclassifier/write(tofile:metadata:).md)

### Inspecting an image classifier model

- [model](createml/mlimageclassifier/model.md)
- [modelParameters](createml/mlimageclassifier/modelparameters-swift.property.md)

### Describing an image classifier

- [description](createml/mlimageclassifier/description.md)
- [debugDescription](createml/mlimageclassifier/debugdescription.md)
- [playgroundDescription](createml/mlimageclassifier/playgrounddescription.md)

### Supporting types

- [MLImageClassifier.DataSource](createml/mlimageclassifier/datasource.md)
- [MLImageClassifier.ModelParameters](createml/mlimageclassifier/modelparameters-swift.struct.md)
- [MLImageClassifier.FeatureExtractorType](createml/mlimageclassifier/featureextractortype.md)
- [MLImageClassifier.CustomFeatureExtractor](createml/mlimageclassifier/customfeatureextractor.md)
- [MLImageClassifier.ImageAugmentationOptions](createml/mlimageclassifier/imageaugmentationoptions.md)

### Default Implementations

- [CustomDebugStringConvertible Implementations](createml/mlimageclassifier/customdebugstringconvertible-implementations.md)
- [CustomPlaygroundDisplayConvertible Implementations](createml/mlimageclassifier/customplaygrounddisplayconvertible-implementations.md)
- [CustomStringConvertible Implementations](createml/mlimageclassifier/customstringconvertible-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomPlaygroundDisplayConvertible](swift/customplaygrounddisplayconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Escapable](swift/escapable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Image models

- [Creating an Image Classifier Model](createml/creating-an-image-classifier-model.md)
- [MLObjectDetector](createml/mlobjectdetector.md)
- [MLHandPoseClassifier](createml/mlhandposeclassifier.md)
