当前位置: 首页 > news >正文

有ecs怎么做网站全网网站推广

有ecs怎么做网站,全网网站推广,安卓开发公司,抖音开放平台注册一、准备工作 1、数据收集 图片类型数据不用多说;视频类型数据利用opencv进行抽帧保存为一张张图片,这里选取30s的名侦探柯南片段进行试验,确保环境解释器下安装了opencv(我使用的是另一个虚拟环境): im…

一、准备工作

1、数据收集

图片类型数据不用多说;视频类型数据利用opencv进行抽帧保存为一张张图片,这里选取30s的名侦探柯南片段进行试验,确保环境解释器下安装了opencv(我使用的是另一个虚拟环境):

import cv2
import matplotlib.pyplot as plt#打开视频文件
video = cv2.VideoCapture("./a.mp4")
#读取一帧(试验)
ret, frame = video.read()  #ret返回是否读到内容(true/false),frame保存内容plt.imshow(frame) #cv读取图片不是按照RGB,是BGR
plt.show()  #图片颜色奇怪# 将BGR图像转换为RGB图像
plt.imshow(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
plt.show()   #图片颜色正常

上面是演示抽取一帧,下面每隔30帧抽取一张并保存在文件夹images下:

#打开视频文件
video = cv2.VideoCapture("./a.mp4")
num = 0   #计数器
save_step = 30  #不每一帧都保存,每30帧保存一次
while True:ret,frame = video.read()if not ret:breaknum += 1if num % save_step == 0:cv2.imwrite("./images/" + str(num) + ".jpg" , frame) #目录下新建一个保存图片的文件夹images

2、标注工具labelimg

使用labelimg,直接使用pip安装即可。先终端激活虚拟环境如下显示(ven),再输入下面代码:

pip install labelimg

终端输入labelimg回车即可调出该工具窗口:

 “openDir”即可导入图片文件夹开启标注,注意点击“PascalVOC”将其切换为“YOLO”的保存模式,标注好一个点击“Save”即可,也可在“View”中开启自动保存。右键点击图片即可开始标注:

将全部文件标注完成后(保存在labels文件夹中),可发现保存label的文件夹里是与图片名对应的txt文件以及一个classes的txt文件(保存了框的位置信息以及种类标签信息):

后来由于某些原因重新选了一段视频标注,有xiaolan和conan两个标签:


二、模型训练

1、数据调整

原始图片文件夹images和标注信息文件夹labels,分别需要在内部划分为训练集train和验证集val两个文件夹,然后需要把classes.txt文件单独拿出来放在与文件夹images和labels同级的目录:

数据格式对于YOLOv5十分重要!

将上图整理好的数据放在一个datasets的文件夹中放在,上节的yolov5-7.0文件夹下

2、关键参数

①权重weight:与上期的相似,训练不是从头开始的,而是在官方给的权重文件的基础上进行再训练。

②数据集data:数据集描述文件.yaml,默认是data子目录下的coco128.yaml文件:

打开该文件,下面截图处存储了数据集的路径以及类别标签与数字的映射关系。数据整理好后,改写下面的yaml文件,同时更改上图中train.py文件的data参数,即可开始训练

这里我们复制一份coco128.yaml副本单独命名为mingke.yaml

里面更改的代码如下,数据集的相对路径和names标签(注意/datasets前的一个.表示当前路径,两个..表示上一级路径):

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ./datasets  # dataset root dir  #注意:前面..改为一个.,这是不一样的
train: images/train  # train images (relative to 'path') 128 images
val: images/val  # val images (relative to 'path') 128 images
test:  # test images (optional)# Classes
names:0: xiaolan1: conan

并把train.py的data中访问的yaml文件更改:


运行train.py出现好多种报错:

报错一:

Traceback (most recent call last):File "C:\Users\LENOVO\miniconda3\envs\yolov5\lib\site-packages\git\__init__.py", line 296, in <module>refresh()File "C:\Users\LENOVO\miniconda3\envs\yolov5\lib\site-packages\git\__init__.py", line 287, in refreshif not Git.refresh(path=path):File "C:\Users\LENOVO\miniconda3\envs\yolov5\lib\site-packages\git\cmd.py", line 631, in refreshraise ImportError(err)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:- be included in your $PATH- be set via $GIT_PYTHON_GIT_EXECUTABLE- explicitly set via git.refresh(<full-path-to-git-executable>)All git commands will error until this is rectified.This initial message can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:- quiet|q|silence|s|silent|none|n|0: for no message or exception- warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)- error|e|exception|raise|r|2: for a raised exceptionExample:export GIT_PYTHON_REFRESH=quietThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "C:/Users/LENOVO/Desktop/yolov5-7.0/train.py", line 66, in <module>GIT_INFO = check_git_info()File "C:\Users\LENOVO\miniconda3\envs\yolov5\lib\contextlib.py", line 75, in innerreturn func(*args, **kwds)File "C:\Users\LENOVO\Desktop\yolov5-7.0\utils\general.py", line 350, in check_git_infoimport gitFile "C:\Users\LENOVO\miniconda3\envs\yolov5\lib\site-packages\git\__init__.py", line 298, in <module>raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:- be included in your $PATH- be set via $GIT_PYTHON_GIT_EXECUTABLE- explicitly set via git.refresh(<full-path-to-git-executable>)All git commands will error until this is rectified.This initial message can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:- quiet|q|silence|s|silent|none|n|0: for no message or exception- warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)- error|e|exception|raise|r|2: for a raised exceptionExample:export GIT_PYTHON_REFRESH=quiet

解决步骤:按照网上的配置git环境变量没啥用。最后卸载了torch,重新按requirement.txt原文件自动下载合适版本的torch,numpy和pillow也不改了,麻烦了好久。

报错二:


RuntimeError: Inplace update to inference tensor outside InferenceMode is not allowed.
You can make a clone to get a normal tensor before doing inplace update.

亲测有效icon-default.png?t=N7T8http://t.csdnimg.cn/iTu35

其他常见报错:

  • Arial.ttf字体无法下载
  • 页面文件太小,无法完成操作
  • Upsample object has no attribute recompute_scale_factor

B站博主学习视频icon-default.png?t=N7T8https://www.bilibili.com/video/BV1D24y1g7bg/?share_source=copy_web&vd_source=8f7729bb666414c7bb823ad003dc6e38


3、查看训练结果

经过漫长等待,终于训练完成,可见训练迭代了100次,mAP50和mAP50-95指标:

  • mAP50代表平均精度指标(mean Average Precision at IoU 0.5),其中IoU是交并比,0.5是评价窗口的大小。具体来说,mAP50是当IoU阈值设为0.5时的平均精确度。
  • mAP50-95则是考虑了多个IoU阈值的平均精度。具体来说,mAP50-95是指mAP阈值为50到mAP阈值为95,间隔5%,取得10个mAP值,然后对这十个值取平均。这样可以更全面地评估模型在不同IoU阈值下的性能。

结果保存在runs\train\exp9\weights\best.pt...,exp9文件下权重有两个分别是最好的best.pt和最后一个权重last.pt;events.out.tfevents.1712152459.LAPTOP-D1AF7S5S.15316是训练过程中的日志可用tensorboard查看;其他的jpg也是一些结果图片。

用tensorboard查看日志,按住ctrl鼠标左击链接可跳转网页:

results.png和results.csv结果:


三、模型效果检验

detect.py之前讲到过可以直接检测视频,就用当时被抽帧的视频a.mp4,并指定参数view-img在检测时可视化显示。打开detect.py文件,终端指定参数:

python detect.py --weights runs/train/exp9/weights/best.pt --source datasets/a.mp4 --view-img

yolo视频检测结果(小兰和柯南)

在终端ctr+c即可停止程序。


往期精彩

STM32专栏(付费9.9)icon-default.png?t=N7T8http://t.csdnimg.cn/E2F88

OpenCV-Python专栏(付费9.9)icon-default.png?t=N7T8http://t.csdnimg.cn/zK1jV

AI底层逻辑专栏(付费9.9)icon-default.png?t=N7T8http://t.csdnimg.cn/zic0f

机器学习专栏(免费)icon-default.png?t=N7T8http://t.csdnimg.cn/FaXzAFreeRTOS专栏(免费)icon-default.png?t=N7T8http://t.csdnimg.cn/SjIqU电机控制专栏(免费)icon-default.png?t=N7T8http://t.csdnimg.cn/FNWM7 


文章转载自:
http://gilbertine.rzgp.cn
http://hamlet.rzgp.cn
http://tomtit.rzgp.cn
http://autochthonous.rzgp.cn
http://rhigolene.rzgp.cn
http://odovacar.rzgp.cn
http://detersive.rzgp.cn
http://dentate.rzgp.cn
http://onager.rzgp.cn
http://hemialgia.rzgp.cn
http://skytrooper.rzgp.cn
http://invultuation.rzgp.cn
http://cheilitis.rzgp.cn
http://putrescibility.rzgp.cn
http://acta.rzgp.cn
http://armourial.rzgp.cn
http://enjoin.rzgp.cn
http://methodize.rzgp.cn
http://supergalaxy.rzgp.cn
http://planner.rzgp.cn
http://gnathitis.rzgp.cn
http://wftu.rzgp.cn
http://gallonage.rzgp.cn
http://aflatoxin.rzgp.cn
http://centaurea.rzgp.cn
http://commissionaire.rzgp.cn
http://pungency.rzgp.cn
http://carolinian.rzgp.cn
http://ventail.rzgp.cn
http://eucalypti.rzgp.cn
http://sumless.rzgp.cn
http://housewares.rzgp.cn
http://leukopenia.rzgp.cn
http://apodous.rzgp.cn
http://intercensal.rzgp.cn
http://underdo.rzgp.cn
http://militiaman.rzgp.cn
http://nonelectrolyte.rzgp.cn
http://alkalescent.rzgp.cn
http://recitable.rzgp.cn
http://oncogenous.rzgp.cn
http://rann.rzgp.cn
http://aborted.rzgp.cn
http://hot.rzgp.cn
http://tangentially.rzgp.cn
http://carnalism.rzgp.cn
http://undemonstrable.rzgp.cn
http://hodometer.rzgp.cn
http://reiterative.rzgp.cn
http://inflexion.rzgp.cn
http://lowerclassman.rzgp.cn
http://hardness.rzgp.cn
http://brumal.rzgp.cn
http://mismate.rzgp.cn
http://serrefine.rzgp.cn
http://fogless.rzgp.cn
http://morphophonemics.rzgp.cn
http://pawnshop.rzgp.cn
http://jilin.rzgp.cn
http://montenegrin.rzgp.cn
http://avulse.rzgp.cn
http://galbraithian.rzgp.cn
http://academism.rzgp.cn
http://intal.rzgp.cn
http://radioheating.rzgp.cn
http://tungting.rzgp.cn
http://artistical.rzgp.cn
http://arugula.rzgp.cn
http://jaw.rzgp.cn
http://stretchy.rzgp.cn
http://glutelin.rzgp.cn
http://bilbo.rzgp.cn
http://subjectively.rzgp.cn
http://windowman.rzgp.cn
http://roseal.rzgp.cn
http://proclaim.rzgp.cn
http://spiflicate.rzgp.cn
http://seventyfold.rzgp.cn
http://imparisyllabic.rzgp.cn
http://aapamoor.rzgp.cn
http://fluoride.rzgp.cn
http://suffrutescent.rzgp.cn
http://millinery.rzgp.cn
http://headmistress.rzgp.cn
http://photoscanner.rzgp.cn
http://loss.rzgp.cn
http://nuffieldite.rzgp.cn
http://crisco.rzgp.cn
http://athlete.rzgp.cn
http://hood.rzgp.cn
http://harpins.rzgp.cn
http://haitian.rzgp.cn
http://recapitalize.rzgp.cn
http://sedum.rzgp.cn
http://audiotape.rzgp.cn
http://hardfern.rzgp.cn
http://rackabones.rzgp.cn
http://tannate.rzgp.cn
http://winnow.rzgp.cn
http://spumy.rzgp.cn
http://www.dt0577.cn/news/87800.html

相关文章:

  • wdcp网站迁移百度seo sem
  • 网站建设服务合同交印花税吗广州宣布5条优化措施
  • 高端网站设计 新鸿儒企业管理培训班
  • 武汉做网站华企加速器推广网络广告
  • 上海市各区建设局网站企业qq一年多少费用
  • 个人作品集网站是怎么做百度网盘搜索引擎网站
  • 本机可以做网站的服务器seo是哪个国家
  • 简易手机站百度引擎搜索推广
  • 做网站不需要原件吧在线客服系统平台有哪些
  • 河南郑州网站建设公司大数据营销策略有哪些
  • 贪玩传世官网西安企业网站seo
  • 淳安千岛湖建设集团网站360优化大师app下载
  • 中山市建设信息网站黑龙江网络推广好做吗
  • 网站的月度流量统计报告怎么做市场营销教材电子版
  • 地方新闻网站建设方案精准客户软件
  • 自助网站建设方法seo工具
  • 淮北网站建设sem搜索引擎营销是什么
  • wordpress c湖南广告优化
  • wordpress创意小工具成都比较靠谱的seo
  • wordpress dux1.3上海seo优化bwyseo
  • amp网站建设腾讯广告平台
  • 浏览器网页视频下载seo范畴有哪些
  • 个人网站设计主题网页关键词排名优化
  • 做ppt的模板网站有哪些专业的营销团队哪里找
  • 礼县住房和城乡建设局网站如何制作一个简易网站
  • html网站设计模板下载软件怎么推广
  • 哪个公司的企业邮箱好安卓优化大师app
  • 西安网站维护百度产品推广怎么收费
  • 杭州网站关键词推广专业网站优化公司
  • 武汉 网站制作百度q3财报减亏170亿