-
Notifications
You must be signed in to change notification settings - Fork 965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem converting ResNeXt-50 MXNet -> Keras #237
Comments
Hi @qubvel python3 -m mmdnn.conversion.examples.keras.imagenet_test -p imagenet1k-resnext-50 -s mxnet -n converted_resnext50 -w mxnet_resnext50.npy -i ./seagull.jpg It's a script for test the accuracy of the conversion, not a must. Error "Local variable 'labels' referenced before assignment" is because that there is no file 'mmdnn/conversion/examples/data/imagenet_1000.txt'. You need to check the newest code. Lambda layer is for group convolution, you can check the converted code file. I test the accuracy of the conversion from resnext50 mxnet to keras. The error is e-6. It's right. |
Hi @namizzz I just want to clarify following:
now:
corrected:
converting script:
P.S. I have the same problem with ResNeXt101, however ResNet models coverts correctly. |
Hi @qubvel, Fixed the bug you mentioned. Thanks very much. Reproduce the conversion with newest MMdnn(0.2.2) (the bug is not merged in newest pip package :( ) $ mmdownload -f mxnet -n imagenet1k-resnext-50 -i mmdnn/conversion/examples/data/seagull.jpg
(396, 0.9810116)
(398, 0.008996904)
(409, 0.0026355518)
(438, 0.0025629073)
(440, 0.0015916944)
$ mmtoir -f mxnet -n ./resnext-50-symbol.json -w ./resnext-50-0000.params -d mxnet_resnext50 --inputShape 3 224 224
IR network structure is saved as [mxnet_resnext50.json].
IR network structure is saved as [mxnet_resnext50.pb].
IR weights are saved as [mxnet_resnext50.npy].
$ mmtocode -f keras -in mxnet_resnext50.pb -iw mxnet_resnext50.npy -d converted_resnext50.py
Parse file [mxnet_resnext50.pb] with binary format successfully.
Target network code snippet is saved as [converted_resnext50.py].
$ python3 -m mmdnn.conversion.examples.keras.imagenet_test -p imagenet1k-resnext-50 -s mxnet -n converted_resnext50 -w mxnet_resnext50.npy -i mmdnn/conversion/examples/data/seagull.jpg
(396, 0.9810091)
(398, 0.008996932)
(409, 0.0026355372)
(438, 0.0025629275)
(440, 0.0015917055) slightly different from MXNet result. But after saving to keras .h5 file and load it again, the prediction result is same with yours. The IR weights file is 145MB, but the .h5 file is only 99M. No idea about this problem, maybe cause by Lambda layer. We will try to figure it out. Thanks for reporting the problem again! |
Hi @kitstar |
Platform (like ubuntu 16.04/win10):
ubuntu 16.04
Python version:
3.6
Source framework with version (like Tensorflow 1.4.1 with GPU):
mxnet 1.2.0 (cpu)
Destination framework with version (like CNTK 2.3 with GPU):
keras (cpu) 2.1.5 (tensorflow 1.7)
Pre-trained model path (webpath or webdisk path):
imagenet1k-resnext-50 (mxnet networks zoo)
Running scripts:
I follow the issue #58 but got the errors while converting the model:
Local variable 'labels' referenced before assignment
here - missed indentation levelTest fails
I converted model as it is using:
mmconvert -sf mxnet -in resnext-50-symbol.json -iw resnext-50-0000.params -df keras -om resnext50.h5 --inputShape 3 224 224
And print sum of outputs of first model layers
Script
Output
Thats seems to be strange to have the same output from all Lambda layers, where previous layer has different values
Script
Output
I dont know why, but all Lambda layers have output as the last 4 feature maps of previous layer.
The text was updated successfully, but these errors were encountered: