How to Train an Image Classifier with Create ML for Your iOS App

A practical, step-by-step guide to training an image classification model in Create ML and preparing it for use in an iOS app — from organizing data to exporting a Core ML file.

What You'll Build and What You Need

An image classifier takes a photo and predicts which category it belongs to — for example, distinguishing product types, plant species, or document kinds. This guide walks through training one in Create ML.

You will need a Mac that runs a current version of Xcode, since Create ML is macOS-only. Create ML is included with Apple's developer tooling.

You will also need labeled images. The more representative your images are of real usage, the better your model performs in the wild.

By the end you will have a Core ML model file ready to drop into an Xcode project. Remember the scope: Create ML trains the model, and you build the actual app separately in Xcode.

Step 1: Organize Your Training Images

Create ML's image classifier expects your data organized as folders, where each folder name is a label. Create one folder per category and place matching images inside.

For instance, a folder named apple holds apple photos, a folder named banana holds banana photos, and so on. The folder name becomes the class the model predicts.

Aim for a balanced dataset. If one class has 500 images and another has 30, the model will tend to be biased toward the larger class. Try to keep counts in the same ballpark.

Capture variety within each class — different lighting, angles, backgrounds, and distances. A model trained only on clean studio shots tends to fail on messy real-world photos.

Step 2: Create a Project in Create ML

Open the Create ML app. On a Mac with Xcode installed, you can launch it from Xcode's Open Developer Tool menu, or find it directly.

Choose New Document, then select the Image Classification template. Give the project a name and a location.

You will see a workspace with sections for training data, validation data, and testing data. This split is what lets you measure whether the model generalizes rather than just memorizes.

Think of the interface as a dashboard. The left side manages your project; the main area is where you drop data and watch training progress. There is no code required at this stage.

Step 3: Add Training and Testing Data

Drag your parent folder — the one containing all the labeled subfolders — into the Training Data well. Create ML reads the folder structure and assigns labels automatically.

Create ML can automatically hold out a portion of your data for validation, or you can supply your own validation set. Validation data guides training and helps catch overfitting.

Keep a separate testing set that the model never sees during training. This is your honest report card. Reserve images the model has never encountered so your accuracy number means something.

Double-check that labels look correct in the interface before training. A mislabeled folder quietly poisons results, and it is far easier to catch now than after a confusing training run.

Step 4: Configure Options and Train

Before training, review the available options. For image classifiers, Create ML typically offers data augmentation settings such as adding noise, blur, cropping, rotation, or flipping to synthetically expand small datasets.

Augmentation helps when you have limited images, but it increases training time. Start conservative and add augmentation if the model struggles to generalize.

Click Train. Create ML uses transfer learning built on models Apple already pre-trained, so training is usually far faster than training from scratch.

Watch the live accuracy and loss curves. Training accuracy tells you how well the model fits your examples; validation accuracy tells you how well it will likely do on new images. You want both to be high and close together.

Step 5: Evaluate the Results

When training finishes, open the Evaluation tab and feed in your held-out testing set. Create ML reports accuracy per class and overall.

Look beyond the headline number. If overall accuracy is high but one class sits far lower, that class needs more or better images.

Use the Preview tab to drag in a few individual photos and see live predictions with confidence scores. This is a quick gut check on real-looking inputs.

If results disappoint, do not just retrain blindly. The usual fixes are more diverse data, better class balance, and cleaner labels — not more training time. Data quality beats iteration count almost every time.

Step 6: Export the Core ML Model

Once you are satisfied, use the export options in Create ML to save the trained model as a Core ML file. This is the artifact your app will use.

Give it a clear, descriptive name. This name becomes the auto-generated Swift class in Xcode, so ProductClassifier is friendlier than Untitled.

Create ML models are often compact because of transfer learning, which is good for app size. Still, check the file size against your app budget, especially if you bundle multiple models.

Keep your Create ML project file too. When you gather more data later, you can retrain and re-export without starting over.

Common Pitfalls to Avoid

A few recurring mistakes cause most disappointing image classifiers, and they are easy to sidestep once you know them.

The first is training on images that do not resemble real usage. If your app classifies photos snapped by users in poor lighting, but you trained only on clean catalog images, accuracy will drop in the field. Match your training data to the conditions your app actually sees.

The second is leakage between splits. If near-identical shots of the same object land in both training and testing, your reported accuracy is inflated and misleading. Keep related images together on one side of the split.

The third is ignoring the confidence scores. An image classifier always returns its best guess, even for inputs that belong to no class at all. In your app, treat low-confidence predictions as uncertain and handle them gracefully rather than acting on every guess.

Finally, do not over-invest before validating the idea. Train a quick first model, see whether the concept works, and only then gather more data to push accuracy higher. Iterating on a working baseline beats polishing a dataset for a model you have not yet proven out.

Step 7: Bring It Into Xcode

Drag the exported Core ML model into your Xcode project navigator and make sure it is added to your app target. Xcode automatically generates a Swift interface for it.

For camera and photo input, the Vision framework pairs naturally with image classifiers. Vision handles resizing and formatting images to what the model expects, which removes a lot of error-prone glue code.

Test on a real device, not just the simulator, since Neural Engine acceleration and real camera input behave differently from a desktop preview.

Finally, remember the boundaries. To ship this to users, you build and sign the app in Xcode and distribute through the App Store with an Apple Developer Program membership. Create ML got you the model; Xcode gets you the app.

Frequently Asked Questions

How many images do I need per category?

There is no fixed minimum, but more diverse, representative images generally help. Thanks to transfer learning you can often start with a modest set, but keep classes balanced and capture varied lighting, angles, and backgrounds.

Why is my validation accuracy much lower than training accuracy?

That gap usually signals overfitting — the model memorized your training images instead of learning general patterns. Add more varied data, balance your classes, and consider augmentation.

Can I train an image classifier without writing code?

Yes. The Create ML app is fully no-code for image classification — you organize folders, drag them in, and click Train. Writing code is only needed later when integrating the model into your app.

Does the model run offline on the device?

Yes. Core ML runs the model on-device, so image classification works offline and keeps images on the user's device rather than sending them to a server.

What format does Create ML export?

It exports a Core ML model file that you add to your Xcode project. Xcode then generates a Swift class so you can call the model from your app code.