Tutorial for exchanging models How to Machine Learning AI Edge

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tutorial for exchanging models How to Machine Learning AI Edge

2,015 Views
Sherlock987
Contributor I

Hello,

I am using the board MCXN947 and the sample project frdmmcxn947_mpp_camera_mobilenet_view_tflm. I have trained my own AI modell and to test I would like to simply switch the trained modell within the sample project. I was able to compile but it does not run. Is there somewhere like a tutorial how to do that?

 

Thanks

0 Kudos
Reply
6 Replies

1,827 Views
Sherlock987
Contributor I

Hello Xu Zhang,

thanks for your help. I was able to swap the model using your template project "frdmmcxn947_tflm_label_image". So, I wanted to go one step further using your template project "frdmmcxn947_mpp_camera_mobilenet_view_tflm".

- I have downloaded the dataset 60'000 images for handwritten digits, inverted the colors (black text, white background), resized to 128x128 and trained the model with eIQ. The validation results for digits 0-9 are above 95%.

- Afterwards I have tested this model successfully on a PC with a webcam.

- Then according to your instruction I have converted the model for Neutron which then should fit to frdmmcxn947 using NPU

Unfortunately I am stuck here because with 947 board the inference result is not accurate at all. I am attaching here a github link, hopefully you can have a look there why it is not working:

https://github.com/SherlockLun/frdmmcxn947_mpp_camera_mnist_view

git@github.com:SherlockLun/frdmmcxn947_mpp_camera_mnist_view.git

 

changed folder:

- models/mnistInverted128... (added)

- models/mobilenetv1_labels.h (digits 0-9)

- models/mobilenetv1_ops_micro_tflite.cpp

- camera_mobilenet_view.c (include file)

- fsl_ov7670.c (changing brightness/contrast within GetDefaultconfig)

 

 

0 Kudos
Reply

1,595 Views
Joey_z
NXP Employee
NXP Employee

Hi,Sherlock987

Thank you for your detailed reply.

I think your inaccurate identification is probably due to the problem of the trained model. I have checked the model_data_len = 1309552 in your model file INT8_out-of-INT8, it is too big ,and I guess your model is not quantized. Please check the options in the following figure during the training of the model using eIQ.

XuZhang_0-1729652285327.png

According to your reply, I used frdmmcxn947_tflm_label_image demo to test the accuracy of static digital data, and I put the modified program in the attachment. The following changes were made:
1. Replace the model.

2. Modify the hexadecimal data of the stopwatch image to that of the digital image. You can use the py script to convert the image, the script is attached, you can use different data to test your model.

XuZhang_1-1729652713381.png

3. Change labels

Then, I use frdmmcxn947_mpp_camera_mobilenet_view_tflm demo to realize the recognition of numbers by the camera. The code is attached. You can replace the trained model for testing. In my testing process, inaccurate model identification also occurred, which was related to many factors, including the number of samples, parameters set in the training process and the results of model quantization.

XuZhang_2-1729652732947.png

Wish it helps you.

BR

Joey

 

 

0 Kudos
Reply

1,800 Views
Joey_z
NXP Employee
NXP Employee

hi,Sherlock987

I will test your project and find the problem as soon as possible.

Whether you have tried static digital picture data in your project. Light intensity, Angle and distance will affect the accuracy of image acquisition by the camera. Please first use static data to check the accuracy of the model.

 

BR

Xu Zhang

0 Kudos
Reply

1,952 Views
Sherlock987
Contributor I

Hello Xu Zhang

Thank you very much for your previous response. It was extremely helpful, and I was able to successfully add my own module.

I currently have the FRDM-MCXN947 evaluation board, the OV7670 camera module, and a 3.5" display. I am experimenting with the project frdmmcxn947_mpp_camera_mobilenet_view_tflm as well as dm-label-cifar10-images-on-mcxn947.

I am currently trying to replace the model with simple dataset such as mnist hand digit recognition and testing the accuracy. I will let you know soon if more support is needed. Thanks!

Best regards

Sherlock

0 Kudos
Reply

1,853 Views
Joey_z
NXP Employee
NXP Employee

Hi,Sherlock987

I'm sorry for not being able to reply you in time. I have received your question and will deal with it as soon as possible.

BR

Xu Zhang

0 Kudos
Reply

1,984 Views
Joey_z
NXP Employee
NXP Employee

hi,Sherlock987

Thank you for contacting technical support.

  1. Use the elQ tool 1.12.1 to convert your model into a .h file.
  2. Replace the model file in the SDK demo with your model file and modify some of its configurations.
  3. Hardware requirements include connecting the Camera module: OV7670 and the 3.5" TFT LCD module by NXP (P/N PAR-LCD-S035) (Note: LCD is not mandatory for viewing the test results).
    I have attached a screen recording of the detailed operation steps. If you encounter any difficulties, you can provide me with your model, and I will offer you better support.

Hope it can help you.

BR 

Xu Zhang

0 Kudos
Reply