本项目是基于 YOLOv13 的汉化优化部署版本,主要针对中文用户进行了深度优化,包括安装依赖包优化、运行脚本重写、一键运行功能等,大幅提升了用户体验。
GitHub 仓库地址: https://github.com/Cgxiaoxin/Yolov13_zh
YOLOv13 引入了革命性的超图计算技术,相比传统YOLO系列有以下显著优势:
模型 | FLOPs (G) | 参数 (M) | AP50:95 | AP50 | AP75 | 延迟 (ms) |
---|---|---|---|---|---|---|
YOLOv8-N | 8.7 | 3.2 | 37.4 | 52.6 | 40.5 | 1.77 |
YOLOv10-N | 6.7 | 2.3 | 38.5 | 53.8 | 41.7 | 1.84 |
YOLOv12-N | 6.5 | 2.6 | 40.1 | 56.0 | 43.4 | 1.83 |
YOLOv13-N | 6.4 | 2.5 | 41.6 | 57.8 | 45.1 | 1.97 |
YOLOv8-S | 28.6 | 11.2 | 45.0 | 61.8 | 48.7 | 2.33 |
YOLOv12-S | 21.4 | 9.3 | 47.1 | 64.2 | 51.0 | 2.82 |
YOLOv13-S | 20.8 | 9.0 | 48.0 | 65.2 | 52.0 | 2.98 |
关键优势:
YOLOv10-N/S, YOLO11-N/S, YOLOv12-N/S, 和 YOLOv13-N/S 的可视化对比示例
自适应超边的代表性可视化示例。前两列的超边主要关注前景中对象间的高阶交互,第三列主要关注背景与部分前景之间的高阶交互。这些超边的可视化可以直观反映YOLOv13建模的高阶视觉关联。
# 创建conda环境
conda create -n yolo13 python=3.9 -y
conda activate yolo13
# 接受conda服务条款(如果遇到错误)
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
# 配置pip镜像源
mkdir -p ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = pypi.tuna.tsinghua.edu.cn
extra-index-url =
https://mirrors.aliyun.com/pypi/simple/
https://pypi.douban.com/simple/
https://pypi.org/simple/
EOF
# 配置conda镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
# 升级pip
pip install --upgrade pip
# 安装PyTorch (CPU版本)
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1
# 安装项目依赖
pip install -r requirements.txt
# 安装项目本身
pip install -e .
# 创建模型目录
mkdir -p model
cd model
# 下载预训练模型
wget https://github.com/iMoonLab/yolov13/releases/download/yolov13/yolov13n.pt
wget https://github.com/iMoonLab/yolov13/releases/download/yolov13/yolov13s.pt
wget https://github.com/iMoonLab/yolov13/releases/download/yolov13/yolov13l.pt
wget https://github.com/iMoonLab/yolov13/releases/download/yolov13/yolov13x.pt
cd ..
# 创建数据集目录
mkdir -p datasets
cd datasets
# 下载COCO数据集
wget https://github.com/ultralytics/assets/releases/download/v0.0.0/coco2017labels.zip
unzip coco2017labels.zip
cd ..
创建 datasets/coco/coco.yaml 文件:
# COCO 2017 dataset configuration
path: ../datasets/coco # dataset root dir
train: images/train2017 # train images (relative to 'path')
val: images/val2017 # val images (relative to 'path')
test: # test images (optional)
# Classes (COCO has 80 classes)
nc: 80 # number of classes
# Class names (COCO 2017)
names:
0: person
1: bicycle
# ... (完整列表见GitHub仓库)
79: toothbrush
# 给脚本添加执行权限
chmod +x run_script/*.sh
# 运行训练
./run_script/run_training.sh
# 运行验证
./run_script/run_validation.sh
# 运行预测
./run_script/run_prediction.sh
# 运行导出
./run_script/run_export.sh
# 交互式选择操作
./run_script/run_all.sh
# 训练模型
python train.py
# 验证模型
python val.py
# 预测图像
python predict.py
# 导出模型
python export.py
from ultralytics import YOLO
# 加载预训练模型
model = YOLO('model/yolov13n.pt')
# 训练模型
results = model.train(
data='datasets/coco/coco.yaml',
epochs=600,
batch=256,
imgsz=640,
device="cpu", # 或 "0" 用于GPU
project='runs/train',
name='yolov13_coco',
)
from ultralytics import YOLO
# 加载训练好的模型
model = YOLO('model/yolov13n.pt')
# 对图像进行预测
results = model.predict(
source='path/to/your/image.jpg',
imgsz=640,
conf=0.25,
save=True,
)
问题: ValueError: Invalid CUDA 'device=0,1,2,3' requested
解决:
# 检查GPU可用性
python -c "import torch; print(torch.cuda.is_available())"
# 如果无GPU,将 device="0,1,2,3" 改为 device="cpu"
问题: ImportError: libGL.so.1: cannot open shared object file
解决:
# 安装OpenGL相关库
apt-get install -y libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-dev libgomp1
# 或使用headless版本
pip install opencv-python-headless
解决:
如果在使用过程中遇到问题,欢迎:
YOLOv13 汉化优化部署版本不仅保留了原论文的技术优势,还针对中文用户进行了深度优化,提供了:
这个项目为中文用户提供了一个高质量、易使用的YOLOv13实现,让先进的超图增强目标检测技术更加普及和实用。