python - Error using CoreML model to classify an image -
i'm trying use coreml tools convert keras model coreml , i'm having error in prediction. first converted model:
coreml_model = coremltools.converters.keras.convert( model, input_names='stampimage', # inform coreml input name image_input_names = 'stampimage', # inform coreml input images output_names='prediction', class_labels = class_labels, # labels_dict predicted_feature_name='predicted_feature_name', is_bgr=true) coreml_model.save('./trained_models_data/stamps' + version + '.mlmodel')
the conversion runs fine. loaded model:
model = coremltools.models.mlmodel('./trained_models_data/stamps' + version + '.mlmodel')
and image:
from pil import image image = image.open('c1243_lnd_899fa3f6-b703-4724-9701-f11dad7cedfe.jpg')
but when tried predict:
model.predict({'stampimage': image})
i received error:
error: value type not convertible: <pil.jpegimageplugin.jpegimagefile image mode=rgb size=714x714 @ 0x1127425a8> --------------------------------------------------------------------------- runtimeerror traceback (most recent call last) <ipython-input-21-82fd85392a7f> in <module>() ----> 1 model.predict({'stampimage': image}) /anaconda/envs/coremltools_py2/lib/python2.7/site-packages/coremltools/models/model.pyc in predict(self, data, **kwargs) 236 """ 237 if self.__proxy__: --> 238 return self.__proxy__.predict(data) 239 else: 240 if _sys.platform != 'darwin' or float('.'.join(_platform.mac_ver()[0].split('.')[:2])) < 10.13: runtimeerror: value type not convertible
i tried follow steps "core ml in depth" session in wwdc... know wrong?
you should load converted model coreml
on ios side. python
use model before conversion.
Comments
Post a Comment