YOLO(You Only Look Once)是一种流行的物体检测和图像分割模型,因其高速度和高精度而迅速受到欢迎。
目前最新版本是YOLO11,项目地址:
https://github.com/ultralytics/ultralytics
安装
pip install ultralytics
yolo detect predict model=yolo11n.pt source='bus.jpg'
物体检测
from ultralytics import YOLO
def yolo_detect():
model = YOLO('yolo11n.pt')
results = model.predict('bus.jpg', save=True)
for result in results:
result.show()
if __name__ == '__main__':
yolo_detect()
分段
def yolo_segment():
model = YOLO('yolo11n-seg.pt')
results = model.predict('bus.jpg', save=True)
for result in results:
result.show()
if __name__ == '__main__':
yolo_segment()
![[yolo-seg.png]]
分类
def yolo_classify():
model = YOLO('yolo11n-cls.pt')
results = model.predict('bus.jpg', save=True)
for result in results:
result.show()
if __name__ == '__main__':
yolo_segment()
姿态
def yolo_pose():
model = YOLO('yolo11n-pose.pt')
results = model.predict('bus.jpg', save=True)
for result in results:
result.show()
if __name__ == '__main__':
yolo_pose()
定向边缘检测
def yolo_obb():
model = YOLO('yolo11n-obb.pt')
results = model.predict('boats.jpg', save=True)
for result in results:
result.show()
if __name__ == '__main__':
yolo_obb()
多目标跟踪
def yolo_track():
model = YOLO('yolo11n.pt')
model.track('car.mp4', show=True, save=True)
if __name__ == '__main__':
yolo_track()
模型
官方训练好的模型有五种尺寸,模型越越大,精度越越高,相对的速度越来越慢,分别是
- yolo11n
- yolo11s
- yolo11m
- yolo11l
- ylol11x
评论区