【PYTHON-YOLOV8N】YOLOV8N的HELLO WORLD
- 环境配置
- 入门代码
- 参考链接
其实官方说的很明白了,这里只是做一个笔记。
环境配置
- 先安装python环境,目前yolo支持python版本
3.8、3.9、3.10、3.11、3.12 - 使用的是python的venv创建虚拟环境,命令是:
python -m venv yolo_env, - 然后激活环境:
yolo_env\Scripts\activate - 安装
pip install -U ultralytics
或者
pip install -U ultralytics -i https://pypi.tuna.tsinghua.edu.cn/simple -i https://mirrors.aliyun.com/pypi/simple/
清华源(推荐,同步最及时)
pip install -U ultralytics -i https://pypi.tuna.tsinghua.edu.cn/simple
阿里云源(国内服务器覆盖广,延迟低)
pip install -U ultralytics -i https://mirrors.aliyun.com/pypi/simple/
腾讯源(适配腾讯云/南方地区,速度快)
pip install -U ultralytics -i https://mirrors.cloud.tencent.com/pypi/simple/
中科大源(老牌稳定源,适合北方地区)
pip install -U ultralytics -i https://pypi.mirrors.ustc.edu.cn/simple/
入门代码
fromultralyticsimportYOLO# Load a COCO-pretrained YOLO11n modelmodel=YOLO("yolo11n.pt")# Display model information (optional)model.info()# Train the model on the COCO8 example dataset for 100 epochsresults=model.train(data="coco8.yaml",epochs=100,imgsz=640)# Run inference with the YOLO11n model on the 'bus.jpg' imageresults=model("path/to/bus.jpg")参考链接
https://docs.ultralytics.com/zh/quickstart/