Use the Coral TPU directly from Python with no arcane libraries (TFLite, PyCoral, Edge TPU Runtime, or any other dungeon monsters)
❗ Getting rid of all dependencies means that the Coral TPU can be easily integrated with ANY device that supports USB.
Wanna run ML on a RPi Zero? on an ESP32 running MicroPython? On your custom ASIC? If you have USB, you can have ML.
Your embedded system / single board computer can use the Coral TPU if it supports:
- Python
- USB (via
pyusb)
Nothing else is needed.
Install USB library:
pip install pyusbPrepare input image: resize to 224x224 and transform to bytes:
from PIL import Image
import sys
path = sys.argv[1]
image = Image.open(path).convert('RGB').resize((224, 224))
image_bytes = image.tobytes()
with open(f'{path.split(".")[0]}.bin', 'wb') as binary_file:
binary_file.write(image_bytes)python install_firmware.pypython inference.py
python install_firmware.pycd object-detectionpython inference.py
Note: If your computer supports
Pillow, you can visualze the bounding boxes after running object detection with:
python object-detection/inference.py my_image.png