Sony's Developer World forum

    • Home
    • Forum guidelines

    Using color images in TFlite

    Spresense
    2
    9
    1607
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Bhalaji Kharthik last edited by Bhalaji Kharthik

      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 errorScreenshot from 2022-04-07 19-24-27.png
      @KamilTomaszewski Please help me with this error.

      K 1 Reply Last reply Reply Quote
      • K
        KamilTomaszewski DeveloperWorld @Bhalaji Kharthik last edited by

        Hi @Bhalaji-Kharthik,

        Please try increasing the TFLM_TENSOR_ARENA_SIZE in your example.

        Best Regards,
        Kamil Tomaszewski

        B 1 Reply Last reply Reply Quote
        • B
          Bhalaji Kharthik @KamilTomaszewski last edited by

          @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?

          K 1 Reply Last reply Reply Quote
          • K
            KamilTomaszewski DeveloperWorld @Bhalaji Kharthik last edited by

            Hi @Bhalaji-Kharthik,

            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 size MY_BUFSIZ to height x width x 3 of the image used by your model.

            Best Regards,
            Kamil Tomaszewski

            B 2 Replies Last reply Reply Quote
            • B
              Bhalaji Kharthik @KamilTomaszewski last edited by Bhalaji Kharthik

              This post is deleted!
              1 Reply Last reply Reply Quote
              • B
                Bhalaji Kharthik @KamilTomaszewski last edited by

                @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?

                K 1 Reply Last reply Reply Quote
                • K
                  KamilTomaszewski DeveloperWorld @Bhalaji Kharthik last edited by

                  Hi @Bhalaji-Kharthik,

                  Is the file you are trying to open in a good format? Try adding printf to the pnm_util.c file and find out what exactly is causing this problem.

                  B 1 Reply Last reply Reply Quote
                  • B
                    Bhalaji Kharthik @KamilTomaszewski last edited by Bhalaji Kharthik

                    Thank You! @KamilTomaszewski 64*64 images are working fine now. Any idea on how big images spresense can handle?

                    K 1 Reply Last reply Reply Quote
                    • K
                      KamilTomaszewski DeveloperWorld @Bhalaji Kharthik last edited by

                      Hi @Bhalaji-Kharthik,

                      It depends on the application. The model, image, application and NuttX must fit into RAM.

                      Best Regards,
                      Kamil Tomaszewski

                      1 Reply Last reply Reply Quote
                      • First post
                        Last post
                      Developer World
                      Copyright © 2021 Sony Group Corporation. All rights reserved.
                      • Contact us
                      • Legal