cv (yolov5)
program that can find patterns or make decisions from a previously unseen dataset.
Note: Drone Computer Vision Repo w/ Datasets
1 - Video/Roboflow: Gather images for dataset
We can film a video of the item we want to detect and then upload to Roboflow. On the Roboflow website, we can extract frames every X seconds to create a .jpg file each interval. Then we can begin labeling each image on Roboflow.
Roboflow is a website where you upload images, label them, and export a zip file (images & .xml files).
Useful to share dataset and have 3 people label at the same time
1.1 - Unlabeled Images to Labeled Images
2 - Colab: Train Custom Model
-The following website uses Python
-here we set up libraries
- collections of pre-written code that you
can use to perform specific tasks
-Prepare the dataset
-Train the model
-Evaluate the model performance with validation data
-Export the model as .tflite file
Open up Google Colab for Yolov5 Training
Follow this video for more details
#made changes to /yolov5train/yolov5/dataset.yaml train: ../data/images/train/ val: ../data/images/valid/ # number of classes nc: 1 # class names names: ['Target']
3 - Export Model
############################# # # ## RESULTS ## # # ############################# # 'download /yolov5/runs/train/exp/weights/best.pt'
Download the best.pt file to upload to Raspberry Pi.
Have a naming convention like '3-27-2024--300epochs-' Demo here
4 - Set up Pi - Installation
Python Library Versions located here
NOTE: (2:54)
-click top left
-preferences
-raspberry pi configuration
-tabs: interfaces
-enable camera
-reboot
sudo apt-get update
git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txt
pip install -r requirements.txt --user
pip install torchvision
mv installs to /.local/python3/dist-packages /usr/local/lib/python3.9/dist-packages/yolov5
cd .local/lib/python3.10/site-packages/
ls # check if packages installed
sudo mv ./* /usr/local/lib/python3.10/dist-packages
5 - Run on Pi
(Note: if on virtual machine for testing): Devices > Webcams > Check Integrated cam box
Download your best.pt file after training, you can use Github or Google Drive
cd yolov5
cp ~/Downloads/best.pt .
gedit detect.py
(Note: make sure you use correct naming convention)
got to line 53 and type:
weights = 'best.pt',
go and comment line 54:
weights = 'yolov5s.pt',
sudo python3 detect.py
sudo python3 detect.py --weights 3-27-13-best.pt --source 0 or sudo python3 detect.py --weights best.pt --source 0
Last updated