Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install object_detect_tf post processing stage #1214

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vivien
Copy link
Contributor

@vivien vivien commented Aug 15, 2023

With this PR, one can add the meta-neural-network layer to their system, enable tensorflow support in libcamera-apps with e.g.:

PACKAGECONFIG:pn-libcamera-apps:append = " tflite"

and try object detection with the new libcamera-detect app or even libcamera-still --post-process-file /usr/share/libcamera-apps/assets/object_detect_tf.json --lores-width 400 --lores-height 300 for example.

(tested on raspberrypi4-64 with a Camera Module 3)

@vivien
Copy link
Contributor Author

vivien commented Aug 17, 2023

tensorflow-lite from meta-neural-network currently only builds for 64-bit systems. Please let me know what I must add in a new commit to skip the build of tensorflow-lite for 32-bit systems (libcamera-apps will build just fine if tensorflow was requested by the user but not available in sysroot.)

@@ -0,0 +1,4 @@
do_install:append () {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find this an issue that needs to be fixed in the actual layer. I'm not sure I understand the reasoning not to do that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right this is a generic change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously that is a generic change that is being discussed upstream. The reasoning behind having a bbappend with the fix in our layer is to document the issue in the meantime, while still providing a functional example to the users. I'm not sure if you noticed, but processing with tensorflow did not work until now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the review is in progress, and it introduces some compile issues. Let's see how that settles upstream (see the symlink discussion). I want to avoid:

  1. introducing new issues while fixing this
  2. making sure that this gets cleaned up after upstream deals with it

The libcamera-apps project provides assets for various built-in,
OpenCV or TensforFlow Lite post processing stages.

Install them as part of the package.

Signed-off-by: Vivien Didelot <[email protected]>
Install the object_detect_tf stage described in the official
documentation:

    https://www.raspberrypi.com/documentation/computers/camera_software.html#object_detect_tf-stage

With libcamera-apps compiled with tflite support, one is able to run
the object detection model with e.g.:

    libcamera-still --post-process-file /usr/share/libcamera-apps/assets/object_detect_tf.json --lores-width 400 --lores-height 300

Signed-off-by: Vivien Didelot <[email protected]>
The tensorflow-lite_2.* recipe from meta-neural-network installs
the library and pkg-config files as tensorflow2-lite*, because their
users may use several versions of the same library.

However packages such as libcamera-apps expect tensorflow-lite* files.

While this is being discussed with the upstream meta-neural-network
layer, adding a dynamic bbappend in meta-raspberrypi also helps
documenting the support for this tensorflow-lite provider.

Refs nnstreamer/meta-neural-network#85

Signed-off-by: Vivien Didelot <[email protected]>
The meta-neural-network provider for tensorflow-lite only builds on
64-bit systems. Set COMPATIBLE_MACHINE to skip the build on 32-bit
variants of the Raspberry Pi SoC family.

Signed-off-by: Vivien Didelot <[email protected]>
@vivien
Copy link
Contributor Author

vivien commented Sep 21, 2023

I've documented the upstream issue in the code and commit message and skipped the build on 32-bit systems (libcamera-apps builds fine when tflite isn't available in sysroot.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants