BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
33.97k stars 18.72k forks source link

Coremltools issue #6926

Open paultas opened 4 years ago

paultas commented 4 years ago

I created .py file according to Apple instruction Apple Instuction and Documentation

import coremltools

# Convert a Caffe model to a classifier in Core ML
coreml_model = coremltools.converters.caffe.convert(
    ('nin_imagenet_conv.caffemodel', 'train_val.prototxt'), predicted_feature_name='class_labels.txt'
)

# Now save the model
coreml_model.save('nin_imagenet_conv.mlmodel')

Then in Terminal I run python convert.py

But then I get a error:

================= Starting Conversion from Caffe to CoreML ======================
Layer 0: Type: 'Data', Name: 'data'. Output(s): 'data', 'label'.
WARNING: Skipping Data Layer 'data' of type 'Data'. It is recommended to use Input layer for deployment.
Layer 1: Type: 'Data', Name: 'data'. Output(s): 'data', 'label'.
WARNING: Skipping Data Layer 'data' of type 'Data'. It is recommended to use Input layer for deployment.
Layer 2: Type: 'Convolution', Name: 'conv1'. Input(s): 'data'. Output(s): 'conv1'.
Layer 3: Type: 'ReLU', Name: 'relu0'. Input(s): 'conv1'. Output(s): 'conv1'.
Layer 4: Type: 'Convolution', Name: 'cccp1'. Input(s): 'conv1'. Output(s): 'cccp1'.
Layer 5: Type: 'ReLU', Name: 'relu1'. Input(s): 'cccp1'. Output(s): 'cccp1'.
Layer 6: Type: 'Convolution', Name: 'cccp2'. Input(s): 'cccp1'. Output(s): 'cccp2'.
Layer 7: Type: 'ReLU', Name: 'relu2'. Input(s): 'cccp2'. Output(s): 'cccp2'.
Layer 8: Type: 'Pooling', Name: 'pool0'. Input(s): 'cccp2'. Output(s): 'pool0'.
Layer 9: Type: 'Convolution', Name: 'conv2'. Input(s): 'pool0'. Output(s): 'conv2'.
Layer 10: Type: 'ReLU', Name: 'relu3'. Input(s): 'conv2'. Output(s): 'conv2'.
Layer 11: Type: 'Convolution', Name: 'cccp3'. Input(s): 'conv2'. Output(s): 'cccp3'.
Layer 12: Type: 'ReLU', Name: 'relu5'. Input(s): 'cccp3'. Output(s): 'cccp3'.
Layer 13: Type: 'Convolution', Name: 'cccp4'. Input(s): 'cccp3'. Output(s): 'cccp4'.
Layer 14: Type: 'ReLU', Name: 'relu6'. Input(s): 'cccp4'. Output(s): 'cccp4'.
Layer 15: Type: 'Pooling', Name: 'pool2'. Input(s): 'cccp4'. Output(s): 'pool2'.
Layer 16: Type: 'Convolution', Name: 'conv3'. Input(s): 'pool2'. Output(s): 'conv3'.
Layer 17: Type: 'ReLU', Name: 'relu7'. Input(s): 'conv3'. Output(s): 'conv3'.
Layer 18: Type: 'Convolution', Name: 'cccp5'. Input(s): 'conv3'. Output(s): 'cccp5'.
Layer 19: Type: 'ReLU', Name: 'relu8'. Input(s): 'cccp5'. Output(s): 'cccp5'.
Layer 20: Type: 'Convolution', Name: 'cccp6'. Input(s): 'cccp5'. Output(s): 'cccp6'.
Layer 21: Type: 'ReLU', Name: 'relu9'. Input(s): 'cccp6'. Output(s): 'cccp6'.
Layer 22: Type: 'Pooling', Name: 'pool3'. Input(s): 'cccp6'. Output(s): 'pool3'.
Layer 23: Type: 'Dropout', Name: 'drop'. Input(s): 'pool3'. Output(s): 'pool3'.
WARNING: Skipping training related layer 'drop' of type 'Dropout'.
Layer 24: Type: 'Convolution', Name: 'conv4-1024'. Input(s): 'pool3'. Output(s): 'conv4'.
Layer 25: Type: 'ReLU', Name: 'relu10'. Input(s): 'conv4'. Output(s): 'conv4'.
Layer 26: Type: 'Convolution', Name: 'cccp7-1024'. Input(s): 'conv4'. Output(s): 'cccp7'.
Layer 27: Type: 'ReLU', Name: 'relu11'. Input(s): 'cccp7'. Output(s): 'cccp7'.
Layer 28: Type: 'Convolution', Name: 'cccp8-1024'. Input(s): 'cccp7'. Output(s): 'cccp8'.
Layer 29: Type: 'ReLU', Name: 'relu12'. Input(s): 'cccp8'. Output(s): 'cccp8'.
Layer 30: Type: 'Pooling', Name: 'pool4'. Input(s): 'cccp8'. Output(s): 'pool4'.
Layer 31: Type: 'Accuracy', Name: 'accuracy'. Input(s): 'pool4', 'label'. Output(s): 'accuracy'.
WARNING: Skipping training related layer 'accuracy' of type 'Accuracy'.
Layer 32: Type: 'SoftmaxWithLoss', Name: 'loss'. Input(s): 'pool4', 'label'. WARNING: Skipping training related layer 'loss' of type 'SoftmaxWithLoss'.

================= Summary of the conversion: ===================================
Traceback (most recent call last):
  File "convert.py", line 5, in <module>
    ('nin_imagenet_conv.caffemodel', 'train_val.prototxt'), predicted_feature_name='class_labels.txt'
  File "/Users/pavel.tarasevich/Library/Python/2.7/lib/python/site-packages/coremltools/converters/caffe/_caffe_converter.py", line 192, in convert
    predicted_feature_name)
  File "/Users/pavel.tarasevich/Library/Python/2.7/lib/python/site-packages/coremltools/converters/caffe/_caffe_converter.py", line 260, in _export
    predicted_feature_name)
RuntimeError: Unable to infer input name and dimensions. Please provide a .prototxt file with 'Input' layer and dimensions defined.