环境搭建与 YOLO 推理实践
选型 · conda 建环境 · 三行推理
YOLOv10 模型谱系 · 模型越大 → 精度越高 / 速度越慢(输入 640)
n
1.84ms
s
m
b
l
x
10.7ms
最轻最快
精度最高
课堂选 YOLOv10n
① 建环境
conda create
-n
YOLO
python=3.12
-y
② 激活 + 装包
conda activate
YOLO
pip install
ultralytics matplotlib
-i
清华源
③ 三行推理
from
ultralytics
import
YOLO
model =
YOLO
(
"yolov10n.pt"
)
model(img, save=
True
, conf=
.05
)
bus.jpg
model 推理
bus .95
检测框 + 置信度
[:, :, ::-1]
OpenCV BGR → matplotlib RGB
B
G
R
R
G
B
否则红蓝互换
加载模型 → 推理 → 可视化
▶ 重播