Create ML Multi-Label Image Classifier will not train, throws error: "Unexpected Error"

Hello everyone, I am new to using Create ML, but am running up against a problem where the error is not descriptive, and I can not figure out what might be causing it. I am fairly sure my data is formatted properly, as in the CreateML software, it detects the images and shows me a bar graph of how many images belong to each label. But when it comes to actually training, the moment I press the "Train" button, it shows an error with the message: "Unexpected Error".

I have also attempted to create and train the model programmatically, and that actually works! The framework requires that the JSON be named "annotations.json" instead of "annotation.json" and that the key representing the name of image be changed to "filename" from "image", but other than that, the data is the same. I tried to use the software with the changes I made to the JSON for use in the framework, but if I try that, it won't even parse the data, so I am fairly sure that my data is formatted correctly.

I would prefer to use the app rather than do everything programmatically, because it presents the data in a much more digestible way.

Has anyone else come up against this issue or a similar issue. I should note that I am running the latest Beta of MacOS Sonoma and Xcode.

Accepted Reply

Thanks for your help with this, this was resolved in the latest Xcode 15, Beta 6. A much more descriptive error of "The training data source should contain more images for each class to enable auto split to include every class." is now shared in this case.

Replies

can you share you Xcode and macOS beta versions?

  • Sure! I’m running MacOS Sonoma Beta 3 (23A5286i) and Xcode 15 Beta 3 (15A5195k).

Add a Comment

and if possible, share a toy dataset that can reproduce it

  • Sure. Here is an iCloud link that contains a screen recording of the issue that's how's that the software correctly parses the json file, but throws an "Unexpected Error" when attempting to train, as well as the exact dataset used in the recording.

  • Thank you, this is very helpful!

Add a Comment

I was wondering if this issue has been resolved?

I am also getting an "Unexpected Error" when I use CreateML to train a model.

In my case, the model is an Action Classifier. CreateML completes the feature extraction phase and then gives me an "Unexpected Error".

I should note that I am running MacOS Ventura 13.4 and Xcode 14.3.1.

Any help is appreciated.

Can anyone share a simple working annotations.json format for the multi-label image classification template? I tried to work out from description above but keep getting 'Data Analysis Stopped' message when adding my training data folder. I think this means something wrong with annotations file.

Hi,

same setup with same issue here.. Stellar, can you share how you managed to train the model programmatically? I could check if my annotations file and the images are at least working ...

Greets

  • I'm sorry, I actually trashed my original file since I decided to wait until Sonoma officially releases to see if my issue is hopefully resolved. I can point you to the official Apple article that I followed though. Hope it helps!

    https://developer.apple.com/documentation/createml/creating-a-multi-label-image-classifier?changes=latest_bet__8_8&language=objc

  • Thx Stellar! I followed that one... but unfortunately I was not able to export my trained model. That is so weird... It worked until these lines:

    // Export to Core ML let modelURL = URL(filePath: "/path/to/model") try model.export(to: modelURL)

    And then it throws: Error loading JSON data: The transformer is not representable as a CoreML model (ImageReader).

Add a Comment

Thanks for your help with this, this was resolved in the latest Xcode 15, Beta 6. A much more descriptive error of "The training data source should contain more images for each class to enable auto split to include every class." is now shared in this case.

I'm getting a failure on export using the exact transformer used in this guide https://developer.apple.com/documentation/createml/creating-a-multi-label-image-classifier

ComposedTransformer<ComposedTransformer<ImageReader, ImageFeaturePrint>, FullyConnectedNetworkMultiLabelClassifierModel> The transformer is not representable as a CoreML model (ImageReader).

I'm guessing this is just a misleading error?

In this intro with no runnable examples https://developer.apple.com/videos/play/wwdc2022/10019/ also noticed this line

try estimator.write(transformer, to: parametersURL) which writes a .pkg file which I'm guessing is for instantiating the estimator