当前位置:网站首页>如何制作数据集并基于yolov5训练成模型并部署
如何制作数据集并基于yolov5训练成模型并部署
2022-06-12 04:16:00 【风吹落叶花飘荡】
如何制作数据集并基于yolov5训练成模型
一个正常的视觉AI开发步骤如下:收集和组织图像、标记您感兴趣的对象、训练模型、将其部署到云端/当做一个端口
一、搜集图片
1、下载已有的数据
如果出于学习,或者应用范围比较广泛,对鲁棒性要求较高,可以使用一些
公开的数据集
知乎地址:https://zhuanlan.zhihu.com/p/25138563
当然这只是公开数据集的一部分,大家可以继续检索到。
其他搜集的找数据集的网站
1.datafountain
https://www.datafountain.cn/datasets
2.聚数力
http://dataju.cn/Dataju/web/searchDataset
3.中文NLP数据集搜索
https://www.cluebenchmarks.com/dataSet_search.html
4.阿里云天池
https://tianchi.aliyun.com/dataset/?spm=5176.12282016.J_9711814210.24.2c656d92n0Us6s
5.谷歌数据集好像要翻墙
2、使用自己拍/在网站上搜集的图片
自己拍的图片那自然是不需要啥操作,直接用即可
下面是使用爬虫下载图片的代码
import os
import sys
import time
import urllib
import requests
import re
from bs4 import BeautifulSoup
import time
header = {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 UBrowser/6.1.2107.204 Safari/537.36'
}
url = "https://cn.bing.com/images/async?q={0}&first={1}&count={2}&scenario=ImageBasicHover&datsrc=N_I&layout=ColumnBased&mmasync=1&dgState=c*9_y*2226s2180s2072s2043s2292s2295s2079s2203s2094_i*71_w*198&IG=0D6AD6CBAF43430EA716510A4754C951&SFX={3}&iid=images.5599"
def getImage(url, count):
'''从原图url中将原图保存到本地'''
try:
time.sleep(0.5)
urllib.request.urlretrieve(url, './imgs/hat' + str(count + 1) + '.jpg')
except Exception as e:
time.sleep(1)
print("本张图片获取异常,跳过...")
else:
print("图片+1,成功保存 " + str(count + 1) + " 张图")
def findImgUrlFromHtml(html, rule, url, key, first, loadNum, sfx, count):
'''从缩略图列表页中找到原图的url,并返回这一页的图片数量'''
soup = BeautifulSoup(html, "lxml")
link_list = soup.find_all("a", class_="iusc")
url = []
for link in link_list:
result = re.search(rule, str(link))
#将字符串"amp;"删除
url = result.group(0)
#组装完整url
url = url[8:len(url)]
#打开高清图片网址
getImage(url, count)
count += 1
#完成一页,继续加载下一页
return count
def getStartHtml(url, key, first, loadNum, sfx):
'''获取缩略图列表页'''
page = urllib.request.Request(url.format(key, first, loadNum, sfx),
headers=header)
html = urllib.request.urlopen(page)
return html
if __name__ == '__main__':
name = "戴帽子" #图片关键词
path = './imgs/hat' #图片保存路径
countNum = 2000 #爬取数量
key = urllib.parse.quote(name)
first = 1
loadNum = 35
sfx = 1
count = 0
rule = re.compile(r"\"murl\"\:\"http\S[^\"]+")
if not os.path.exists(path):
os.makedirs(path)
while count < countNum:
html = getStartHtml(url, key, first, loadNum, sfx)
count = findImgUrlFromHtml(html, rule, url, key, first, loadNum, sfx,
count)
first = count + 1
sfx += 1
二、标注图片
1、在线标注网站MAKE SENSE
MAKE SENSE
make-sense 是一个被YOLOv5官方推荐使用的图像标注工具。
相比于其他工具,make-sense的上手难度非常低,仅需数分钟,玩家便能熟练掌握工作台中的功能选项,快速地进入工作状态;此外,由于make-sense是一款web应用,各个操作系统的玩家可打破次元壁实现工作协同。
a、创建标签
新建一个名为labels的文件,按照每行为一个标签的原则,依次输入
栗子如下:
b、MAKE SENSE标注网站使用
打开网站
点击放入图片
全选搜集到的图片并确认
根据标注需求点击对应的,在这里我们点击物体检测
点击Load labels from file。表示从文件中批量导入标签
放入后点击Create labels list
最后点击开始项目,就可以开始标注了

依次标注每一个图片
导出标注结果
选择导出格式,并导出

导出压缩包参考如下:
到这里图片与标签就都准备好了,可以准备开始制作数据集
三、制作数据集
1、创建文件夹
创建文件夹mydata
其内部构造如下

2、将之前的图片以及标注数据拷贝进去
test与train集合一般比例为2:8或3:7

3、新建一个mydata.yaml文件,

4、修改train.py中data参数



边栏推荐
- Will subsequent versions support code block search highlighting
- Drop down menu dropdown yyds dry inventory of semantic UI
- MySQL的check约束数字问题
- PostgreSQL basic introduction and deployment
- Notes on relevant knowledge points such as original code / inverse code / complement code, size end, etc
- R language plot visualization: plot visualization grouped violin plot in R with plot
- 疫情数据分析平台工作报告【6.5】疫情地图
- Unity脚本出现missing时的解决方法
- Manually encapsulate a foreacht and map
- Sed command
猜你喜欢

【C语言】封装接口(加减乘除)

Function realization and application of trait

Network tester operation manual renix rack management
![[C language] analysis of variable essence](/img/b4/13a5800f2c960ec590c9f7480b09d0.png)
[C language] analysis of variable essence

In 2022, don't you know the difference between arrow function and ordinary function?

Enterprise Architect v16

Successfully solved: warning: there was an error checking the latest version of pip
![[software tool] [original] tutorial on using VOC dataset class alias batch modification tool](/img/25/31d771c9770bb7f455f35e38672170.png)
[software tool] [original] tutorial on using VOC dataset class alias batch modification tool

Emperor Wu of Wei knew that he could not correct it, so he stopped offering his words

Esp32c3 remote serial port
随机推荐
【C语言】封装接口(加减乘除)
R language write function: use the write function to write data to the rstudio console, and the write function to write data to a new rstudio window (start a new window)
绝对定位使盒子居中显示的三种方式
无线物联网WiFi模块方案,ESP32-S3芯片技术,助力设备智能化
Call reminder
Function realization and application of trait
Work report of epidemic data analysis platform [6.5] epidemic map
MySQL create user and authorize
Ebpf series learning (4) learn about libbpf, co-re (compile once – run everywhere) | use go to develop ebpf programs (cloud native tool cilium ebpf)
Implementation of fitness club management system based on SSH
疫情数据分析平台工作报告【6.5】疫情地图
动规(14)-三角形最佳路径问题
根據變換矩陣進行圖像拼接
数据库新建表,以前没问题的,今天
UI consistency design of products
2.28 (defect filling) data type conversion exception handling part multi threading
Esp32c3 remote serial port
[fpga+gps receiver] detailed design introduction of dual frequency GPS receiver based on FPGA
La mise en évidence de la recherche par blocs est - elle prise en charge dans les versions ultérieures?
[C language] encapsulation interface (addition, subtraction, multiplication and division)