1. 准备环境 Preparing the Environment
注意Pytorch版本问题 https://pytorch.org/get-started/locally/
git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -U -r requirements.txt # -q
python3 -c "from yolov5.utils.google_utils import gdrive_download; gdrive_download('1n_oKgR81BJtqk75b00eAjdv03qVCQn2f','coco128.zip')"
2. 配置分类 Configurations
# yaml file
path: ../datasets/person # dataset root di
train: images/train2017 # train images (relative to 'path') 128 images
val: images/train2017 # val images (relative to 'path') 128 images
nc: 1 # number of classes
names: [ 'person' ]
3. 创建标签 Image Annotation
# images folder + labels folde
| ---- yolov5
| ---- datasets
| | --- images
| | --- train
| | --- train_1.jpg
| | --- ...
| | --- train_n.jpg
| | --- val
| | --- val_1.jpg
| | --- ...
| | --- val_n.jpg
| | --- labels
| | --- train
| | --- train_1.txt
| | --- ...
| | --- train_n.txt
| | --- val
| | --- val_1.txt
| | --- ...
| | --- val_n.txt
# labeling
pip install labelimg
labelimg
4. 训练模型 Retraining
python train.py --img 640 --batch 16 --epochs 100 --data ./data/person.yaml --cfg ./models/yolov5s.yaml
5. 部署和推理 Deploy and Inferencing
python detect.py --weight person.pt --source 0
https://colab.research.google.com/drive/1gDZ2xcTOgR39tGGs-EZ6i3RTs16wmzZQ#scrollTo=GD9gUQpaBxNa
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。