
通过Google Colab平台训练yolov5模型,实现对可乐罐的识别
1 2 3 4 5 6 7 8 9 10
| !git clone https://github.com/ultralytics/yolov5 %cd yolov5 %pip install -qr requirements.txt
import torch from IPython.display import Image, clear_output
clear_output() print('Setup complete. Using torch %s %s' % (torch.__version__, torch.cuda.get_device_properties(0) if torch.cuda.is_available() else 'CPU'))
|
1 2 3
| !python detect.py --weights yolov5s.pt --img 640 --conf 0.25 --source data/images/ Image(filename='runs/detect/exp/zidane.jpg', width=600)
|
1 2
| !python train.py --img 640 --batch 50 --epochs 200 --data /content/yolo_C/A.yaml --weights yolov5s.pt --nosave --cache
|
1 2 3 4
| !python detect.py --weights /content/yolov5/runs/train/exp/weights/last.pt --img 640 --conf 0.25 --source ../test1.jpg
Image(filename='runs/detect/exp2/test1.jpg', width=600)
|
效果图:
