0

I have created an ML Model using Create ML, which is about emotion recognition.

As an input file, I have uploaded a CSV file. The data consists of 48x48 pixel grayscale images of faces. The faces have been automatically registered so that the face is more or less centered and occupies about the same amount of space in each image. The task is to categorize each face based on the emotion shown in the facial expression into one of seven categories (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral).

The model which I got has more than 87% accuracy, but when I use it in my Xcode project I get the following error:

  func setup() {
    do {
      // Gender request
      requests.append(VNCoreMLRequest(
        model: try VNCoreMLModel(for: GenderNet().model),
        completionHandler: handleGenderClassification
      ))
      // Age request
      requests.append(VNCoreMLRequest(
        model: try VNCoreMLModel(for: AgeNet().model),
        completionHandler: handleAgeClassification
      ))
      // Emotions request
      requests.append(VNCoreMLRequest(
        model: try VNCoreMLModel(for: test().model),
        completionHandler: handleEmotionClassification
      ))
    } catch {
      assertionFailure("Can't load Vision ML model: \(error)")
    }
  }
      Fatal error: Can't load Vision ML model: Error Domain=com.apple.vis Code=15 
    "The model does not have a valid input feature of type image"
    UserInfo={NSLocalizedDescription=The model does not have a valid input feature of type image}:
    file /Users/ivandimitrov/Desktop/Faces/Faces/ClassificationService.swift, line 38

Do you have any ideas on how to fix that?

dmzza
  • 2,308
  • 1
  • 21
  • 33
Dakata
  • 1,227
  • 2
  • 14
  • 33

1 Answers1

2

Your input is not being recognized as an image, you can verify this by clicking on your model in Xcode: enter image description here My input is of type Image, but yours is likely another type.

When running your conversion script eg coremltools.converters.tensorflow.convert(model, ...), you need to provide the parameter image_input_names which should match the name of your input layer.

Enrique Avina
  • 973
  • 7
  • 20