microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.8k stars 965 forks source link

Caffe 'Clip' KeyError when converting from Caffe code to Caffe model #836

Closed Xargonus closed 4 years ago

Xargonus commented 4 years ago

Platform: Ubuntu 18.04

Python version: 3.6.9

Source framework with version: Tensorflow 1.15.2

Destination framework with version: Caffe-cpu

Pre-trained model path (webpath or webdisk path): https://github.com/spectrico/car-color-classifier-yolo3-python/blob/master/model-weights-spectrico-car-colors-mobilenet-224x224-052EAC82.pb

Running scripts: mmtomodel -f caffe -in caffe_converted.py -iw caffe_converted.npy -o caffe_target

I have the caffe-cpu ubuntu package installed. The Clip layer is implemented in the layers, but 'Clip' is not in the param names, which are read from caffe_pb2.py, resulting in this bug:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/caffe/net_spec.py", line 160, in _to_proto _param_names[self.type_name] + '_param'), k, v) KeyError: 'Clip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/xargonus/.local/bin/mmtomodel", line 8, in sys.exit(_main()) File "/home/xargonus/.local/lib/python3.6/site-packages/mmdnn/conversion/_script/dump_code.py", line 79, in _main ret = dump_code(args.framework, args.inputNetwork, args.inputWeight, args.outputModel, args.dump_tag) File "/home/xargonus/.local/lib/python3.6/site-packages/mmdnn/conversion/_script/dump_code.py", line 32, in dump_code save_model(MainModel, network_filepath, weight_filepath, dump_filepath) File "/home/xargonus/.local/lib/python3.6/site-packages/mmdnn/conversion/caffe/saver.py", line 9, in save_model MainModel.make_net(dump_net) File "caffe_converted.py", line 151, in make_net print(n.to_proto(), file=fpb) File "/usr/lib/python3/dist-packages/caffe/net_spec.py", line 193, in to_proto top._to_proto(layers, names, autonames) File "/usr/lib/python3/dist-packages/caffe/net_spec.py", line 97, in _to_proto return self.fn._to_proto(layers, names, autonames) File "/usr/lib/python3/dist-packages/caffe/net_spec.py", line 162, in _to_proto assign_proto(layer, k, v) File "/usr/lib/python3/dist-packages/caffe/net_spec.py", line 64, in assign_proto is_repeated_field = hasattr(getattr(proto, name), 'extend') AttributeError: min

TobeyQin commented 4 years ago

Thank you for your report. I will fix this ASAP

goncz commented 4 years ago

What was the solution to this issue?

linmajia commented 4 years ago

@goncz , I've replied to your issue.