就像我的视觉和CoreML框架一样,却陷入了如何使用我自己的重新训练模型的困境 . 我尝试用基于this tutorial的Keras训练VG16模型 . 除了一些Keras版本警告外,一切看起来都不错 . 然后我尝试使用以下代码使用CoreMLTools转换结果模型

coremlModel = coremltools.converters.keras.convert(
    kmodel,
    input_names = 'image',
    image_input_names = 'image',
    output_names = 'classLabelProbs',
    class_labels = ['cats', 'dogs'],
)

在转换过程中,它给了我一些版本兼容的警告,但是否则它成功了:

WARNING:root:Keras version 2.0.6 detected. Last version known to be fully compatible of Keras is 2.0.4 .
WARNING:root:TensorFlow version 1.2.1 detected. Last version known to be fully compatible is 1.1.1 .

所以我将这个模型加载到Apple的Vision ML示例代码中,但每次我尝试对图像进行分类时都会失败并出现错误

Vision+ML Example[2090:2012481] Error: The VNCoreMLTransform request failed
Vision+ML Example[2090:2012481] Didn't get VNClassificationObservations 
Error Domain=com.apple.vis Code=3 "The VNCoreMLTransform request failed" UserInfo={NSLocalizedDescription=The VNCoreMLTransform request failed, NSUnderlyingError=0x1c025d130 {Error Domain=com.apple.CoreML Code=0 "Dimensions of layer 'classLabelProbs' is not the same size as the number of class labels." UserInfo={NSLocalizedDescription=Dimensions of layer 'classLabelProbs' is not the same size as the number of class labels.}}}

我猜这是因为预训练的VGG16模型已经有1000个类别,所以我尝试了1000个类别和1000个2(猫和狗)类别,但仍然遇到了同样的问题 .

我错过了什么吗?我非常感谢任何线索和帮助 .