Micropython implementation of the Person Detection Example
I was able to restore the tflite model from the person_detection_int8 archive. It was a .cc file but I converted it back into a binary file and verified the architecture in netron.
I was able to create this (96,96) binary file from the corresponding .cc file from the person_detection_int8 archive.
I was able to create this (96,96) binary file from the corresponding .cc file from the person_detection_int8 archive.
A script that runs in python3 to load and display the two test images.
Download the latest build of the micropython unix port:
- Click on "Actions" tab.
- Click on "Select Workflow" button.
- Choose "UNIX"
- Click on the commit message name for the most recent successful build
- Click on microlite-unix-micropython in the "Artifacts" area to download a zip file containing the micropython command for unix. It can also run within the windows subsystem for linux.
Run micropython /examples/person_detection/person_detection.py
~/git/tensorflow-micropython-examples/examples/person_detection$ ./micropython ./person_detection.py
interpreter_make_new: model size = 300568, tensor area = 139264
Classify No Person Image
setup 9612 bytes on the inputTensor.
'not a person' = -25, 'person' = 25
Classify Person Image
setup 9612 bytes on the inputTensor.
'not a person' = -113, 'person' = 113
NOTE: The person detection model is 300 kb so you need to use a board with SPI RAM
Download the latest build of the micropython microlite spiram board for the esp32 port:
- Click on "Actions" tab.
- Click on "Select Workflow" button.
- Choose "ESP32"
- Click on the commit message name for the most recent successful build
- Click on microlite-spiram-16m-esp32-firmware in the "Artifacts" area to download a zip file containing the esp32 firmware you can now flash.
After flashing upload these files from here onto the board:
- no_person_image_data.dat
- person_image_data.dat
- person_detect_model.tflite
- person_detection.py
Then import person_detection to run the example:
This has been tested using an ESP32-CAM-MB and an M5 Timer Camera using the MICROLITE_SPIRAM_CAM Firmware.
Flash that firmware and then copy the esp32-cam/person_detection_cam.py and person_detect_model.tflite model to the camera.
Run import person_detection_cam to activate the demo program. The led will illuminate when it thinks a person is in frame.