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

Add FaceID Examples for MAX78002, Add requirements.txt for db_gen Utility, Fix AttributeError for db_gen Utility #537

Merged
merged 10 commits into from
Apr 10, 2023

Conversation

aniktash
Copy link
Contributor

@aniktash aniktash commented Apr 4, 2023

No description provided.

Copy link
Contributor

@vicloginov vicloginov Apr 4, 2023

Choose a reason for hiding this comment

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

There is no Feather for MAX78002. Remove this figure.

Copy link
Contributor

@vicloginov vicloginov left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Contributor

Choose a reason for hiding this comment

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

This picture needs to be updated to MAX78002 EVKIT

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this figure

Copy link
Contributor

@Jake-Carter Jake-Carter left a comment

Choose a reason for hiding this comment

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

Looks good - just a minor updated needed to the readme.

I also need to do 2 things before merging. I'll get the items below done asap.

  1. Create a requirements.txt for the db_gen utility. I had some issues last week with my ai8x-synthesis venv generating unexpected embeddings with the utility. Victor identified potential dependency issues. I will validate a clean venv against the prerequisites listed in the readme to confirm and create a requirements.txt file.

  2. Run an MSDKGen update to sync the project files with the latest v1.6.0

#include "embedding_process.h"
#include "keypad.h"

#if 0 // Custom camera settings
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


PR_DEBUG("Camera Manufacture ID is %04x\n", id);

#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


* Uncomment `TFT = ADAFRUIT` in [project.mk](project.mk) to use drivers for the legacy [Adafruit 3315](https://www.adafruit.com/product/3315). Otherwise, the default drivers for the [NewHaven NHD-2.4-240320CF](https://newhavendisplay.com/2-4-inch-premium-spi-resistive-tft-display/) will be used.

### Load firmware image to MAX78002 EVKIT
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this section in favor of pointing to the MSDK User Guide. See the new MSDKGen README template for the new recommended sections.

i.e. just add...

### Project Usage

Universal instructions on building, flashing, and debugging this project can be found in the **[MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/)**.

... Underneath the ##FaceID Demo Software section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

aniktash and others added 5 commits April 7, 2023 11:04
- AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?
@Jake-Carter
Copy link
Contributor

@aniktash @vicloginov

Added requirements.txt (616549c), and on a clean virtual environment the db_gen works as expected.

FYI for numpy > 1.20 np.int is deprecated. I updated the scripts to use int instead as recommended by the error message (see d33243e)

/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/db_gen/mtcnn/utils/detect_face.py:70: UserWarning: The given NumPy array is not writable, and PyTorch does not support non-writable tensors. This means writing to this tensor will result in undefined behavior. You may want to copy the array to protect its data or make it writable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:206.)
  imgs = torch.as_tensor(imgs, device=device) # pylint: disable=no-member
Traceback (most recent call last):
  File "/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/./db_gen/generate_face_db.py", line 95, in <module>
    main()
  File "/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/./db_gen/generate_face_db.py", line 91, in main
    create_db_from_folder(args)
  File "/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/./db_gen/generate_face_db.py", line 57, in create_db_from_folder
    embedding_db, _ = append_db_file_from_path(args.db, face_detector, ai85_adapter,
  File "/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/db_gen/utils.py", line 196, in append_db_file_from_path
    img = get_face_image(img, mtcnn)
  File "/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/db_gen/utils.py", line 263, in get_face_image
    img_arr, _, _, _ = generate_image(img, box, 1)
  File "/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/db_gen/utils.py", line 295, in generate_image
    new_box = np.round(new_box).astype(np.int)
  File "/home/jakecarter/repos/fork/msdk/Examples/MAX78002/CNN/faceid_evkit/venv/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?

@Jake-Carter Jake-Carter changed the title ported faceID from MAX78000 and clang-formatted Add FaceID Examples for MAX78002, Add requirements.txt for db_gen Utility, Fix AttributeError for db_gen Utility Apr 10, 2023
@Jake-Carter Jake-Carter added MAX78000 Related to the MAX78000 (AI85) MAX78002 Related to the MAX78002 (AI87) labels Apr 10, 2023
@Jake-Carter
Copy link
Contributor

@aniktash @vicloginov

Also FYI: I updated the readme with jumper settings here: 7e1b7f2

After testing, I found that the camera initialization was unreliable. The default jumper settings install extra pull-ups that degrade the communication. All I2C1 pull-ups on the EVKIT should be uninstalled, since the DVP Camera Adapter board has built-in I2C pull-ups.

With that issue resolved, the camera initialization became reliable and the demo functions as expected.

@Jake-Carter
Copy link
Contributor

Build_Examples workflow is not checking out the correct branch. The build test is passing for the changes in this PR.

@Jake-Carter Jake-Carter merged commit 6a86cd3 into analogdevicesinc:main Apr 10, 2023
@aniktash aniktash deleted the faceID_port_MAX78002 branch April 11, 2023 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MAX78000 Related to the MAX78000 (AI85) MAX78002 Related to the MAX78002 (AI87)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants