Closed LiYingwei closed 6 years ago
Hi @LiYingwei,
For MXNet resnet50,
The input shape is 3224224, not 299299, you need to modify the mmtoir* command.
The preprocess function is transposing the image from RGB format to BGR format.
Did you apply the preprocess function? Thanks.
@kitstar , Thanks for helping me. I indeed didn't consider these things. I will try to fix them and see if it can work.
Also, before you reply, I tried to debug by myself. Firstly I want to make sure tensorflow part could work properly, so I followed this page to test if I can correctly convert tf model to IR and then convert back to tf model.
So I run these scripts:
mmdownload -f tensorflow -n resnet_v2_152
mmtoir -f tensorflow -d resnet152 -n imagenet_resnet_v2_152.ckpt.meta -w imagenet_resnet_v2_152.ckpt --dstNodeName MMdnn_Output
mmtocode -f tensorflow --IRModelPath resnet152.pb --IRWeightPath resnet152.npy --dstModelPath tf_resnet152.py
python -m mmdnn.conversion.examples.tensorflow.imagenet_test -s tf -p resnet -n tf_resnet152 -w resnet152.npy
When I run line 4, I got an error:
imagenet_test.py: error: argument -s: invalid choice: u'tf' (choose from 'mxnet', 'keras', 'cntk', 'pytorch', 'caffe', 'tensorflow')
So I change tf to tensorflow and run it again. This time the program tell me
IOError: [Errno 2] No such file or directory: u'mmdnn/conversion/examples/data/seagull.jpg'
So I make these dirs and download the jpg file from github. Finally, it could run. However, the model I generate by commend 1-3 cannot pass this test. I edit the line 309 (in the released version the line# is 241) of imagenet_test.py and print the prediction and then I found 3 of 5 is not correct.
I am wondering if there is anything wrong in this part.
Hi @LiYingwei , If you want to try the inference result of the model from mxnet, you can try:
python -m mmdnn.conversion.examples.tensorflow.imagenet_test -s mxnet -p imagenet1k-resnet-152 -n mx_resnet50.py -w resnet50.npy -i your_image_path
For seagull.jpg, we can got [(21, 0.49690375), (144, 0.40759432), (23, 0.057171866), (146, 0.03169549), (22, 0.0018843169)]
In imagenet 1k labels, 21, 22, 23, 144 are common prediction results. And the mobel will give you all 1000 classes probability, you can show top-n as you want.
Ubuntu 14.04
Python version: 2.7
Tensorflow 1.4.0 with GPU
Pre-trained model path: download using mmdownload
Running scripts:
I successfully got mx_resnet50.py
But when I load the weight and feed images, the output are always equal to 818. Please help.