当前位置:网站首页>[YOLOv5] 6.0 environment construction (updated from time to time)
[YOLOv5] 6.0 environment construction (updated from time to time)
2022-08-08 23:08:00 【The swaying tree】
引言
笔者YOLOv5专栏链接导航:
The author has always been very partialyolov5系列,Because it is very friendly,上手容易,Compatibility is also relatively high(There won't be many demanding requirements,Especially for training hardware configuration),From building the environment to training to application,都非常简便.Let users spend more time on coordination and improvement of actual application scenarios.
yolov5的最新版本6.1
源码:https://github.com/ultralytics/yolov5/tree/v6.1
Some updated information notes:https://github.com/ultralytics/yolov5/releases/tag/v6.1Author update date : 2022.3.2
1.环境搭建
conda create -n yolov5-6 python=3.7
conda activate yolov5-6
官网的安装教程:
Generally run to downloadtorch会非常慢,So it is best to install it separately firsttorch
The author's installation instruction flow is as follows:
git clone https://github.com/ultralytics/yolov5 # 1
cd yolov5 # 2
pip install -r requirements.txt # 3
Follow the prompts to decide which version to install,如上图所示
官网安装命令 https://pytorch.org/get-started/locally/
# 单独安装pythorch(gpu版本)
install torch==1.10.2+cu102 torchvision==0.11.3+cu102 torchaudio===0.10.2+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html # 4
# Run the official installation instructions again,At this point the installation will be much faster
pip install -r requirements.txt # 5
If other necessary libraries are encountered, the download is very slow,Then you can install and use the mirror source separately
pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install xxx -i https://pypi.douban.com/simple
# 然后再
pip install -r requirements.txt
requirements.txt的内容如下:
2.下载预训练模型
链接(Scroll to the bottom of the page):预训练模型
3. 推理
任意新建一个.py文件,写入如下的代码,在终端运行
import torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # or yolov5m, yolov5x, custom
# Images
# img = 'https://ultralytics.com/images/zidane.jpg' # or file, PIL, OpenCV, numpy, multiple
img = 'data/images/zidane.jpg'
# Inference
results = model(img)
# Results
results.print() # or .show(), .save(), .crop(), .pandas(), etc.
显示结果为:
4. 测试
--project
指定保存路径;--weights
指定测试模型
python detect.py --source data/images/zidane.jpg --weights v5_pre_models/yolov5s.pt --project out --img-size 640
边栏推荐
猜你喜欢
随机推荐
wsgw login packet capture record
加载 已训练模型 张量的 几种方法
动手写prometheus的exporter-01-Gauge(仪表盘)
(2022杭电多校三)1002-Boss Rush(状压DP+二分)
wps表格怎么筛选出需要的内容?wps表格筛选出需要的内容的方法
Introduction to Qt (5) - file operation, hotkey and mouse reading (implementation of txt window)
2022杭电多校六 1007-Shinobu loves trip(同余方程)
Hi3516 使用 wifi模块
Dynamic Host Configuration Protocol DHCP (DHCPv4)
(codeforce547)C-Mike and Foam(质因子+容斥原理)
LeetCode:最长有效括号
Kubernetes 实现 CI/CD 发布流程
【PP-YOLOv2】测试自定义的数据集
wps a3格式怎么转换成a4?wps a3格式转换成a4的方法
bp神经网络的学习心得
Analysis of WLAN - Wireless Local Area Network
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
The second side of Tencent technical support internship - Tencent's father's luck is so sudden (offer received)
积性函数
详解JS中for...of、in关键字