neo-ai / neo-ai-dlr

Neo-AI-DLR is a common runtime for machine learning models compiled by AWS SageMaker Neo, TVM, or TreeLite.
Apache License 2.0
491 stars 107 forks source link

DLR inference issue on raspberry pi (custom trained model) #68

Open jwpwhite opened 5 years ago

jwpwhite commented 5 years ago

System Information

Describe the problem

  1. Trained custom bird classification model using this notbook: https://github.com/gabehollombe-aws/jupyter-notebooks

  2. Following the steps in https://aws.amazon.com/blogs/aws/amazon-sagemaker-neo-train-your-machine-learning-models-once-run-them-anywhere/ to convert a MXNET resnet50 model to one for Raspberry pi 3B.

  3. Testing image: /dlr-1.0-py2-armv7l/tests/dog.npy Runs without an issue if I use resnet50 model under /dlr-1.0-py2-armv7l/models

  4. If I use my own custom trained model, probabilities or zero are returned for bird images or for the dog.npy. Seem the code I used below.

  5. As you can see in https://github.com/jwpwhite/birdpi-rp-dlr/blob/master/neotest.py#L40 this is how I'm trying to run the inference, but as I mentioned it is giving me probabilities of zero when using my own custom trained model linked to below.

Code: https://github.com/jwpwhite/birdpi-rp-dlr Default model: resnet50 model included in /home/pi/dlr-1.0-py2-armv7l/models/resnet50 Custom model: https://www.dropbox.com/s/nc35wwuhemcrfjp/model-rasp3b.tar.gz?dl=0

hcho3 commented 5 years ago

@jwpwhite In https://github.com/jwpwhite/birdpi-rp-dlr/blob/master/neotest.py#L8, you should set the number of the output classes to 8, to be consistent with the synset. Also, try running your model with MXNet (before uploading the model to Neo) and see if you get non-zero outputs.