YOLOv5🚀是一个在COCO数据集上预训练的物体检测架构和模型系列,它代表了Ultralytics对未来视觉AI方法的公开研究,其中包含了在数千小时的研究和开发中所获得的经验和最佳实践。
- 安装Anconda
- Anconda 虚拟环境添加新路径
conda config --add envs_dirs 你的envs路径
- Anconda 清华源配置
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
若安装paddle出错,可以修改镜像源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
- 创建yolo虚拟空间
conda create -n 命名 python=选择合适的python版本
像这样
conda create -n yolo python=3.8
- 进入yolo虚拟空间
conda activate yolo
- git yolo仓库,我用的yolo版本是v5 选择合适的目录(不要有中文命名的目录)打开cmd
git clone [email protected]:ultralytics/yolov5.git
使用了加速源下载,放心下载不会慢 7. 进入下载好的yolo目录,下载依赖
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
如果需要使用wandb,还要下载一个 wandb
pip install wandb -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install labelimg -i https://pypi.tuna.tsinghua.edu.cn/simple
git clone [email protected]:a1046700338/yolo5.git
or git clone https://github.com/a1046700338/yolo5.git
File -> Settings -> Project:yolo5 -> Python Interpreter -> add -> Conda Enviroment -> Existing Enviroment -> 选择你的虚拟环境路径 -> ok
将你的数据集文件复制到项目根目录下,并在 data
目录下创建一个yaml文件,自行命名,
yaml文件内容:
train: ../train/images #你的数据集路径
val: ../valid/images #你的有效集路径
nc: 2 #你的classes数量
names: ['mask', 'no-mask'] #数组内是你的classes,标签
之后修改 train.py
第460行代码,即可
parser.add_argument('--data', type=str, default='data/文件名.yaml', help='data.yaml path')
所有环境配置好后,运行 train.py