- Experiment with YOLO on the Jetson Nano.
- Use Python, PyTorch, and TorchVision for deep learning and object detection.
- Use YOLO to Detect faces and objects on photos, videos, and live camera streams.
- Ubuntu 18.04
- Python 3
- Nvidia Jetpack 4.3-b134
- Pytorch v1.8.0
- TorchVision v0.9.0
- YOLO v7
YOLO (You Only Look Once) is a state-of-the-art object detection algorithm that has gained popularity due to its efficiency and accuracy in detecting and identifying objects in images and videos.
One of the main advantages of YOLO is its ability to perform real-time object detection, making it suitable for use in applications such as video surveillance, autonomous vehicles, and augmented reality.
Installation1. Download and install Nvidia JetPack
- Download the latest SD card image from: https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#write
- Boot up Jetson Nano and do initial setup
2. Download and install pre-requisites
- $ sudo apt update
- $ sudo apt install python3-pip
- $ sudo apt install libfreetype6-dev
- $ pip3 install --upgrade pip setuptools wheel
- $ python3 -m pip install --upgrade --force-reninstall pip
- $ pip3 install numpy==1.19.4
3. Download and install YOLO v7 repository
- $ git clone https://github.com/WongKinYiu/yolov7.git
- $ cd yolov7
4. Edit then run requirements.txt file
- $ gedit requirements.txt
- comment out Matplotlib, Numpy, opencv-python, Torch, Torchvision, thop (these are installed elsewhere)
- $ pip3 install -r requirements.txt
4. Download PyTorch v1.8.0
- download torch-1.8.0-cp36-cp36m-linux_aarch64.whl
- $ wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl -O torch-1.8.0-cp36-cp36m-linux_aarch64.whl
- $ sudo apt-get install python3-pip libopenblas-base libopenmpi-dev libomp-dev
- $ pip3 install Cython
- $ pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl
5. Download and install TorchVision
- $ sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
- $ git clone --branch v0.9.0 https://github.com/pytorch/vision torchvision
- $ cd torchvision
- $ export BUILD_VERSION=0.9.0
- $ python3 setup.py install --user
Command: python3 detect
YOLO Command
python3 detect.py --weights yolov7-tiny.pt --conf 0.25 --img-size 640 --source inference/images/people.jpg
YOLO Command
python3 detect.py --weights yolov7-tiny.pt --conf 0.25 --img-size 640 --source inference/images/animals.png
YOLO Command
python3 detect.py --weights yolov7-tiny.pt --conf 0.25 --img-size 640 --source inference/images/people.mp4
Video: 19 seconds
Time to detect: ~4 minutes
Test 4 – Video File (mov)YOLO Command
python3 detect.py --weights yolov7-tiny.pt --conf 0.25 --img-size 640 --source inference/images/traffic.mov
Video: 30 seconds
Time to detect: ~8 minutes
Test 5 – Live Video
YOLO Command
python3 detect.py --weights yolov7-tiny.pt --conf 0.25 --img-size 640 --source 0
ConclusionI was able to successfully implement YOLO on the Nvidia Jetson Nano, and it did a very good job of detecting objects in photos, videos, and live stream. The video rendering was quite slow, probably due to the limited resources of the Nano, but in the end, the results were impressive!
Comments