Bootstrap

YOLOv5的详细使用教程,以及使用yolov5训练自己的数据集

YOLOv5的详细使用教程,以及使用yolov5训练自己的数据集

文章目录:


本人环境声明:

  • 系统环境Ubuntu18.04.1
  • cuda版本10.2.89
  • cudnn版本7.6.5
  • torch版本1.5.0
  • torchvision版本0.6.0
  • 项目代码yolov5官网,项目开源的时间:20200601

自定义数据集:


1 安装环境依赖


1.1 克隆项目

git clone https://github.com/ultralytics/yolov5 # clone repo

如果下载比较慢,建议使用下面的镜像下载:

git clone https://github.com.cnpmjs.org/ultralytics/yolov5 # clone repo


1.2 安装必要的环境依赖

官方给出的要求是:python>=3.7PyTorch>=1.5,安装依赖:

cd yolov5
pip install -U -r requirements.txt
requirements.txt

# pip install -U -r requirements.txt
Cython
numpy==1.17
opencv-python
torch>=1.5
matplotlib
pillow
tensorboard
PyYAML>=5.3
torchvision
scipy
tqdm
git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI

# Nvidia Apex (optional) for mixed precision training --------------------------
# git clone https://github.com/NVIDIA/apex && cd apex && pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" . --user && cd .. && rm -rf apex

# Conda commands (in place of pip) ---------------------------------------------
# conda update -yn base -c defaults conda
# conda install -yc anaconda numpy opencv matplotlib tqdm pillow ipython
# conda install -yc conda-forge scikit-image pycocotools tensorboard
# conda install -yc spyder-ide spyder-line-profiler
# conda install -yc pytorch pytorch torchvision
# conda install -yc conda-forge protobuf numpy && pip install onnx  # https://github.com/onnx/onnx#linux-and-macos


2 下载预训练模型和标注的数据集


2.1 下载预训练模型


2.1.1 执行脚本下载预训练模型

/yolov5/weights/download_weights.sh脚本定义下载预训练模型,脚本代码内容如下:

#!/bin/bash
# Download common models

python3 -c "from utils.google_utils import *;
attempt_download('weights/yolov5s.pt');
attempt_download('weights/yolov5m.pt');
attempt_download('weights/yolov5l.pt');
attempt_download('weights/yolov5x.pt')"

attempt_download函数/yolov5/utils/google_utils.py脚本中定义


2.1.2 直接下载预训练模型,然后保存到/yolov5/weights目录下即可,我已经把预训练模型的url提取出来

大家直接在google driver中下载即可,地址(可能需要科学上网):

点我——》带你去:https://drive.google.com/drive/folders/1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J


2.2 下载标注的数据集


2.2.1 执行脚本下载

;