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.79k stars 965 forks source link

Error when convert a keras-retinanet model to caffe #523

Open tengfly opened 5 years ago

tengfly commented 5 years ago

Platform (like ubuntu 16.04/win10): Windows Python version: 3.5.5 Source framework with version (like Tensorflow 1.4.1 with GPU): Keras 2.2.2; tensorflow 1.8.0; all with GPU Destination framework with version (like CNTK 2.3 with GPU): Caffe with GPU Pre-trained model path (webpath or webdisk path):

Running scripts: mmconvert -sf keras -iw ./resnet50_csv_50.h5 -df caffe -om resnet50_csv_050.prototxt --inputShape 500,500,3

Error: Using TensorFlow backend. e:\programdata\anaconda3\envs\tensorflow\lib\importlib_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds) Traceback (most recent call last): File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\mmdnn\conversion\keras\keras2_parser.py", line 104, in init from keras.applications.mobilenet import relu6 ImportError: cannot import name 'relu6'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "e:\programdata\anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "e:\programdata\anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "e:\ProgramData\Anaconda3\envs\tensorflow\Scripts\mmconvert.exe__main.py", line 9, in File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\mmdnn\conversion_script\convert.py", line 102, in _main ret = convertToIR._convert(ir_args) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\mmdnn\conversion_script\convertToIR.py", line 46, in _convert parser = Keras2Parser(model) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\mmdnn\conversion\keras\keras2_parser.py", line 120, in init 'DepthwiseConv2D': layers.DepthwiseConv2D File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 260, in load_model model = model_from_config(model_config, custom_objects=custom_objects) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 334, in model_from_config return deserialize(config, custom_objects=custom_objects) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\layers__init.py", line 55, in deserialize printable_module_name='layer') File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\engine\network.py", line 1017, in from_config process_layer(layer_data) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\engine\network.py", line 1003, in process_layer custom_objects=custom_objects) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\layers\init.py", line 55, in deserialize printable_module_name='layer') File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\utils\generic_utils.py", line 147, in deserialize_keras_object return cls.from_config(config['config']) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\engine\base_layer.py", line 1109, in from_config return cls(*config) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper return func(args, **kwargs) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\layers\normalization.py", line 75, in init super(BatchNormalization, self).init__(**kwargs) File "e:\programdata\anaconda3\envs\tensorflow\lib\site-packages\keras\engine\base_layer.py", line 128, in init__ raise TypeError('Keyword argument not understood:', kwarg) TypeError: ('Keyword argument not understood:', 'freeze')

rainLiuplus commented 5 years ago

Hi @tengfly , it looks like a problem with keras or tensorflow, maybe you can go to Stack Overflow to find a answer.

kmader commented 5 years ago

I have the same issue, AttributeError: module 'keras_applications.mobilenet' has no attribute 'relu6'

It looks like this is the line that fails https://github.com/Microsoft/MMdnn/blob/f62a33a7d6834680537693c7fdc7e90e1b2382ef/mmdnn/conversion/keras/keras2_parser.py#L109 Which makes sense since keras has recently split the models and pretraining from the main repo https://github.com/keras-team/keras-applications

ccsone commented 5 years ago

hello did you solved your error? now i need to convert the retinanet based on keras to caffe. you uesd the mmdnn to convert it directly?