# YOLO_V5 **Repository Path**: wzjahucm/yolov5 ## Basic Information - **Project Name**: YOLO_V5 - **Description**: YOLO V5官方源码改安中医教学 - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-09-26 - **Last Updated**: 2026-04-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # YOLO V5环境搭建 ## 一、准备 1. 安装Anaconda 百度搜索“windows安装anaconda”关键词 2. Anaconda换源 百度搜索“windows换清华源anaconda”关键词 3. 查看yolo v5官方安装文档(https://github.com/ultralytics/yolov5),要求在 Python>=3.8.0 环境中安装 requirements.txt ,且要求 PyTorch>=1.8 ![](https://gitee.com/wzjahucm/yolov5/raw/master/img/python_requir.jpg "图片标题") 4. 创建Anaconda子环境 ``` # 创建一个 conda 环境,环境名称为yolov5 conda create -n yolov5 python=3.8 # 激活yolov5环境 conda activate yolov5 ``` ![](https://gitee.com/wzjahucm/yolov5/raw/master/img/conda_env_create.jpg "图片标题") 5. 安装PyTorch ``` # CPU Only conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cpuonly -c pytorch ``` ## 二、克隆源代码 在Anaconda命令行中输入以下命令,查看环境,并进入到代码目录中 克隆YOLO V5源代码并安装依赖 代码地址:[汪子健/yolov5](https://gitee.com/wzjahucm/yolov5) (也可根据github官方克隆: https://github.com/ultralytics/yolov5 ) - 可百度搜索"windows git 安装 csdn",安装git工具 打开git bash窗口,克隆仓库 ``` git clone https://gitee.com/wzjahucm/yolov5.git ``` ![](https://gitee.com/wzjahucm/yolov5/raw/master/img/open_git.jpg "图片标题") ![](https://gitee.com/wzjahucm/yolov5/raw/master/img/git_clone.jpg "图片标题") ## 三、进入环境并进入YOLOV5目录 ``` # 查看所有conda环境 conda env list # 激活yolov5环境 conda activate yolov5 # 查看yolov5环境中安装的所有包(重点检查Torch版本) pip list # 进入到YOLOV5的代码目录 cd C:\Users\wzjah\Desktop\Coding\YOLOV5 ``` ## 四、YOLO V5目标检测任务 1. 标注 makesense在线标注官网:https://www.makesense.ai/ ,教程可自行百度搜索makesense 标注关键词 2. 安装依赖(**注意,此处需要进入代码目录并在Anaconda命令行中运行**) ``` pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple some-package ``` 3. 训练 - 我们的人员检测数据集在/data/human_detection_dataset目录下 - 在data目录下创建human_detection.yaml数据配置文件,文件内容如下: ``` # 人形检测 path: data/human_detection_dataset # dataset root dir train: train/images val: valid/images test: # test images (optional) # Classes names: 0: person ``` - 训练 ``` python train.py --data data/human_detection.yaml --weights yolov5s.pt --img 640 --batch-size 2 ``` 可进入runs/train目录查看训练结果 4. 实时检测 将runs/train/exp6/weights/best.pt文件拷贝到YOLOV5根目录下,执行: ``` python detect.py --weights best.pt --source 0 --device cpu ```