文章目录[隐藏]
1. 拉取代码
git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txt
2. 模型测试
import torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # or yolov5m, yolov5x, custom
# Images
img = 'https://sup.51qudong.com/wp-content/uploads/csmbjc/zidane.jpg' # or file, PIL, OpenCV, numpy, multiple
# Inference
results = model(img)
# Results
results.print() # or .show(), .save(), .crop(), .pandas(), etc.
3. 通过detect.py测试
$ python detect.py --source 0 # webcam
file.jpg # image
file.mp4 # video
path/ # directory
path/*.jpg # glob
'https://youtu.be/NUsoVlDFqZg' # YouTube video
'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream
版权声明:本文为CSDN博主「令狐傻笑」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/linghu8812/article/details/117459639
暂无评论