Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
Using color images in TFlite
-
I am trying tfmlrt_lenet type program but with color images. So inorder to load color image as input I used stbi_load instead of pnm_load and changed MNIST_SIZE_PX to 128X128X3. The application build was successful but when i executed it in the nuttx shell i got the followng error
@KamilTomaszewski Please help me with this error. -
Please try increasing the
TFLM_TENSOR_ARENA_SIZE
in your example.Best Regards,
Kamil Tomaszewski -
@KamilTomaszewski Thank you I increased the TF ARENA size the error was rectified. The tflite example provided uses pgm format which is black and white images.Is there any specific example on how to handle classification of color images using tflite in spresense?
My guess was instead of loading pgm format images I tried to load jpg images using stbi library, so am I going in the right direction or is there ways to change the main file in example provided to be suitable for color images? -
You can use jpg files from the stb library. However, you have to be careful because the RGB image will be bigger than JPG.
You can also use
pnm_util.c
file and ppm format. This file also works with the P6 header. You just need to change the sizeMY_BUFSIZ
to height x width x 3 of the image used by your model.Best Regards,
Kamil Tomaszewski -
This post is deleted! -
@KamilTomaszewski Thank you! I am trying to change the image size being given in the tflmrt example. The program works fine 28 * 28 but when i try to change the MNIST_PX size in main file and BUFF_SIZE in pnm util file i get the error pgm image unable to upload due to -22. I also tried increasing stack size. Any ideas what causes this error and how to rectify it?
-
Is the file you are trying to open in a good format? Try adding
printf
to thepnm_util.c
file and find out what exactly is causing this problem. -
Thank You! @KamilTomaszewski 64*64 images are working fine now. Any idea on how big images spresense can handle?
-
It depends on the application. The model, image, application and NuttX must fit into RAM.
Best Regards,
Kamil Tomaszewski