0

I'm running this out-of-the-box turi python code:

import turicreate as tc
# Load the data
data =  tc.SFrame('annotations.sframe')

# Make a train-test split
train_data, test_data = data.random_split(0.8)

# Create a model
model = tc.object_detector.create(train_data, model="darknet-yolo", max_iterations=1, verbose=True)

# Save predictions to an SArray
predictions = model.predict(test_data)

# Evaluate the model and save the results into a dictionary
metrics = model.evaluate(test_data)

# Save the model for later use in Turi Create
model.save('mymodel.model')

# Export for use in Core ML
model.export_coreml('MyCustomObjectDetector.mlmodel')

But on the last line I'm getting the error: model.export_coreml('MyCustomObjectDetector.mlmodel')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/amir/anaconda/envs/CowsVision/lib/python2.7/site-packages/turicreate/toolkits/object_detector/object_detector.py", line 1477, in export_coreml
    mlmodel = coremltools.models.MLModel(model)
  File "/Users/amir/anaconda/envs/CowsVision/lib/python2.7/site-packages/coremltools/models/model.py", line 209, in __init__
    self.__proxy__ = _get_proxy_from_spec(filename)
  File "/Users/amir/anaconda/envs/CowsVision/lib/python2.7/site-packages/coremltools/models/model.py", line 103, in _get_proxy_from_spec
    return _MLModelProxy(filename)
RuntimeError: Error compiling model: "Error reading protobuf spec. validator error: The .mlmodel supplied is of version 3, intended for a newer version of Xcode. This version of Xcode supports model version 2 or earlier.".
>>> 

In the console.

Does that mean that my local installed xcode version needs upgrade? Where is the .mlmodel version being determined? What's "this version of Xcode"?

Amir A.Eitan
  • 183
  • 1
  • 12
  • I reinstalled to the latest Xcode 10 beta, and the problems persists. – Amir A.Eitan Jun 16 '18 at 18:36
  • 2
    Note that you're using beta software. The first releases of Xcode after WWDC are usually a little behind what they actually show at the conference, and they start to become usable at beta 2 or 3. Have patience. :-) – Matthijs Hollemans Jun 17 '18 at 09:14
  • I was getting the same error also when I was on earlier, more stable version of Xcode. – Amir A.Eitan Jun 17 '18 at 13:21
  • As far as I know, object detection isn't supported by the current (iOS 11) version of Core ML, even though Turi Create lets you build such models. – Matthijs Hollemans Jun 18 '18 at 09:18
  • They have a whole example on the developer site about exporting the model to coreml so I'm not sure what do you mean. – Amir A.Eitan Jun 18 '18 at 13:19
  • I meant that Core ML in iOS 11 cannot do object detection models, at least not without a lot of help (it does not do any of the post-processing such as NMS). The mlmodel that the current _beta_ version of Turi Create writes is of version 3 of the spec. It looks like the current Xcode beta cannot read mlmodel version 3 files yet, only version 2 (as of iOS 11.2) and 1 (as of iOS 11.0). – Matthijs Hollemans Jun 18 '18 at 15:37
  • oh! Is there a way to use an earlier version of Turi create then? – Amir A.Eitan Jun 18 '18 at 16:25
  • 1
    You could check out the branch `release_4.3`. – Matthijs Hollemans Jun 18 '18 at 18:10

1 Answers1

0

Per the comments above, I've downgraded to turicreate 4.0 version and the problem was solved for me. It looks like the most recent beta version (5.1) isn't working well.

Amir A.Eitan
  • 183
  • 1
  • 12