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

越秀网站建设天津百度爱采购

越秀网站建设,天津百度爱采购,美食网站设计规划书,网站建设 迅雷下载基于yolo的小球位置实时检测 Yolo安装 操作系统:ubuntu 安装cuda和opencv git clone https://github.com/pjreddie/darknet.git cd darknet 修改Makefile文件,使GPU1,OPENCV1 make 2. 数据集处理 2.1 制作数据集 将小球放在摄像头前…

基于yolo的小球位置实时检测

  1. Yolo安装

操作系统:ubuntu

安装cuda和opencv

git clone https://github.com/pjreddie/darknet.git

cd darknet

修改Makefile文件,使GPU=1,OPENCV=1

make

2. 数据集处理

2.1 制作数据集

将小球放在摄像头前面,截取500张不同位置的图片,如图2-1所示。尽可能的保证图像的清晰度,不要有幻影。

图2-1 制作数据集

2.2 图片名顺序编号

截取500张图片之后,需要将图片从000-499顺序编号,如图2-2所示。

图2-2 图片顺序标号

可以通过如下python程序实现:

#coding:utf-8

import os

path = "./b/"

dirs = os.listdir(path)

print type(dirs)

for i in range(0,500):

    oldname = path + dirs[i]

    newname = path + "%03d"%i +".jpg"

    os.rename(oldname,newname)

图2-3 train.txt文件

2.3 生成train.txt文件

新建文件夹VOCdevkit,在VOCdevkit文件夹下新建三个文件夹Annotation、ImageSets和JPEGImages,并把准备好的自己的原始图像放在JPEGImages文件夹下。在ImageSets文件夹中,新建空文件夹Main,然后把写了训练或测试的图像的名字的文本拷到Main文件夹下,即train.txt文件,如图2-3所示。

可以通过如下python程序实现:

file = open('train.txt','w')

for i in range(0,500):

    file.write(str("%03d"%i)+'\n')

file.close()

2.4 生成xml文件

通过标注工具labelimg来图片进行标注,生成xml文件。Github地址为:https://github.com/tzutalin/labelImg

生成的xml文件保存到Annotation文件夹下,格式如下:

<?xml version="1.0"?>

<annotation>

<folder>JPEGImages</folder>

<filename>000.jpg</filename>

<path>/home/byl/dl/yolo/darknet/scripts/VOCdevkit/BALL2007/JPEGImages/000.jpg</path>

<source>

<database>Unknown</database>

</source>

<size>

<width>800</width>

<height>600</height>

<depth>3</depth>

</size>

<segmented>0</segmented>

<object>

<name>ball</name>

<pose>Unspecified</pose>

<truncated>0</truncated>

<difficult>0</difficult>

<bndbox>

<xmin>330</xmin>

<ymin>38</ymin>

<xmax>357</xmax>

<ymax>65</ymax>

</bndbox>

</object>

</annotation>

2.5 生成txt文件

将VOCdevkit放到scripts目录下,运行voc_label.py文件,会在VOCdevkit文件下生成labels文件夹,000.txt-499.txt会生成在labels文件夹下。格式为:0 0.428125 0.0841666666667 0.03375 0.045。同时,会在scripts文件夹下生成2007_train.txt文件,如图2-4所示。

图2-4 2007_train.txt文件

修改voc_label.py代码如下:

import xml.etree.ElementTree as ET
import pickle
import os
from os import listdir, getcwd
from os.path import join

#sets=[('2012', 'train'), ('2012', 'val'), ('2007', 'train'), ('2007', 'val'), ('2007', 'test')]

#classes = ["aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]

sets = [('2007','train')]
classes = ["ball"]

def convert(size, box):
    dw = 1./(size[0])
    dh = 1./(size[1])
    x = (box[0] + box[1])/2.0 - 1
    y = (box[2] + box[3])/2.0 - 1
    w = box[1] - box[0]
    h = box[3] - box[2]
    x = x*dw
    w = w*dw
    y = y*dh
    h = h*dh
    return (x,y,w,h)

def convert_annotation(year, image_id):
    in_file = open('VOCdevkit/BALL%s/Annotations/%s.xml'%(year, image_id))
    out_file = open('VOCdevkit/BALL%s/labels/%s.txt'%(year, image_id), 'w')
    tree=ET.parse(in_file)
    root = tree.getroot()
    size = root.find('size')
    w = int(size.find('width').text)
    h = int(size.find('height').text)

    for obj in root.iter('object'):
        difficult = obj.find('difficult').text
        cls = obj.find('name').text
        if cls not in classes or int(difficult)==1:
            continue
        cls_id = classes.index(cls)
        xmlbox = obj.find('bndbox')
        b = (float(xmlbox.find('xmin').text), float(xmlbox.find('xmax').text), float(xmlbox.find('ymin').text), float(xmlbox.find('ymax').text))
        bb = convert((w,h), b)
        out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')

wd = getcwd()

for year, image_set in sets:
    if not os.path.exists('VOCdevkit/BALL%s/labels/'%(year)):
        os.makedirs('VOCdevkit/BALL%s/labels/'%(year))
    image_ids = open('VOCdevkit/BALL%s/ImageSets/Main/%s.txt'%(year, image_set)).read().strip().split()
    list_file = open('%s_%s.txt'%(year, image_set), 'w')
    for image_id in image_ids:
        list_file.write('%s/VOCdevkit/BALL%s/JPEGImages/%s.jpg\n'
%(wd, year, image_id))
        convert_annotation(year, image_id)
    list_file.close()

3.训练神经网络

3.1 修改tiny-yolo-voc.cfg

修改cfg/tiny-yolo-voc.cfg如下:

[convolutional]  

size=1  

stride=1  

pad=1  

filters=30  //修改最后一层卷积层核参数个数,计算公式是依旧自己数据的类别数filter=num×(classes + coords + 1)=5×(1+4+1)=30  

activation=linear  

  

[region]  

anchors = 1.08,1.19,  3.42,4.41,  6.63,11.38,  9.42,5.11,  16.62,10.52  

bias_match=1  

classes=1  //类别数,本例为1类  

coords=4  

num=5  

softmax=1  

jitter=.2  

rescore=1  

  

object_scale=5  

noobject_scale=1  

class_scale=1  

coord_scale=1  

  

absolute=1  

thresh = .6  

random=1  

3.2 修改voc.names文件

现在检测的类只有一个ball,删除data/voc.names中的内容,写入ball。

3.3 修改voc.data文件

    修改voc.data文件内容如下:

    classes= 1

train  = /home/byl/dl/yolo/darknet/scripts/2007_train.txt

//valid  = /home/byl/dl/yolo/darknet/2007_test.txt

names = data/voc.names

backup = backup

图3-1 训练网络

3.4 训练网络

在darknet目录下,输入./darknet detector train cfg/voc.data cfg/tiny-yolo-voc.cfg,即可开始训练。如图3-1所示。

4.最终结果

4.1 终极模型

对目标进行检测,需要模型文件。模型的好坏直接影响最终的检测见过。对训练log进行分析,来判断模型是否训练到了最佳,如表4-1所示。AVG IOU的值越大,测试结果会越好。表中的0.0,0.1…分别代表AVG IOU 0.0,AVG IOU 0.1…。

训练次数

0.0

0.1

0.2

0.3

0.7

0.8

0.9

47万-53万

1

6

150

1311

185100

127817

1874

53万-55万

1

2

35

362

61803

46824

880

55万-61万

0

7

85

825

178128

147453

3405

61万-63万

0

2

21

185

51183

45038

1149

63万-69万

1

7

82

657

193275

183137

5572

69万-71万

0

0

18

187

63576

64266

2234

118万-121万

0

0

6

84

70550

100660

7199

121万-126万

0

1

18

188

145083

209911

15962

126万-128万

0

0

7

54

42951

59009

4284

128万-133万

0

1

17

181

137936

207057

16287

133万-135万

0

0

6

74

47243

69910

5404

表4-1 训练log分析

通过表可知,大约训练到120万次时,训练结果趋于稳定,不会再有太大的变化。由于数据量太大,训练log和最终训练的模型将会放在TITAN X电脑Ubuntu系统家目录下的项目/01-小球位置实时检测目录下。

4.2 检测结果

用历时三周训练了135万次的模型检测的结果如图4-1所示。还有录制的检测结果的视频、训练数据文件,数据标定文件等均在上节所述文件夹。

 

图4-1 检测结果

 


文章转载自:
http://dinncoaccoutrements.wbqt.cn
http://dinncoeffulge.wbqt.cn
http://dinncoiridosmium.wbqt.cn
http://dinncocosmine.wbqt.cn
http://dinncotowering.wbqt.cn
http://dinncowomanhood.wbqt.cn
http://dinncocastigator.wbqt.cn
http://dinncowigwam.wbqt.cn
http://dinncohyperfragment.wbqt.cn
http://dinncoacock.wbqt.cn
http://dinncomayoral.wbqt.cn
http://dinncocassation.wbqt.cn
http://dinncobindlestiff.wbqt.cn
http://dinncoconjunct.wbqt.cn
http://dinncodisembroil.wbqt.cn
http://dinncosmote.wbqt.cn
http://dinncoincommunicative.wbqt.cn
http://dinncolovemaking.wbqt.cn
http://dinncokymograph.wbqt.cn
http://dinncopicasso.wbqt.cn
http://dinncomicrofilaria.wbqt.cn
http://dinncoprogression.wbqt.cn
http://dinncolysin.wbqt.cn
http://dinncohaemolyze.wbqt.cn
http://dinncorhinoceros.wbqt.cn
http://dinncotrengganu.wbqt.cn
http://dinncodilemmatic.wbqt.cn
http://dinnconormalcy.wbqt.cn
http://dinncomaladjustive.wbqt.cn
http://dinncoantilepton.wbqt.cn
http://dinncoautochthonic.wbqt.cn
http://dinncodisinfest.wbqt.cn
http://dinncocomandante.wbqt.cn
http://dinncoostracism.wbqt.cn
http://dinncoinimically.wbqt.cn
http://dinncoparameter.wbqt.cn
http://dinncohaori.wbqt.cn
http://dinncoundrape.wbqt.cn
http://dinncovagi.wbqt.cn
http://dinncosymptomize.wbqt.cn
http://dinncopertinence.wbqt.cn
http://dinncoastp.wbqt.cn
http://dinncopatroness.wbqt.cn
http://dinncoclementine.wbqt.cn
http://dinncofiltrable.wbqt.cn
http://dinncorethink.wbqt.cn
http://dinncohydrolab.wbqt.cn
http://dinncochildproof.wbqt.cn
http://dinncotike.wbqt.cn
http://dinncobscp.wbqt.cn
http://dinncodeed.wbqt.cn
http://dinncodilatant.wbqt.cn
http://dinncoduvetyn.wbqt.cn
http://dinncoconch.wbqt.cn
http://dinncosst.wbqt.cn
http://dinncohelotry.wbqt.cn
http://dinncoadmire.wbqt.cn
http://dinncoroughneck.wbqt.cn
http://dinncofederally.wbqt.cn
http://dinncoprojector.wbqt.cn
http://dinncohockey.wbqt.cn
http://dinncotebet.wbqt.cn
http://dinncovaccinee.wbqt.cn
http://dinncomaoriness.wbqt.cn
http://dinncopaginary.wbqt.cn
http://dinncolathering.wbqt.cn
http://dinncorebuff.wbqt.cn
http://dinncoagripower.wbqt.cn
http://dinncodiploma.wbqt.cn
http://dinncoax.wbqt.cn
http://dinncoauditoria.wbqt.cn
http://dinncospatterdock.wbqt.cn
http://dinncosalicylaldehyde.wbqt.cn
http://dinncononboarding.wbqt.cn
http://dinncokeypad.wbqt.cn
http://dinncosubjugation.wbqt.cn
http://dinncopeoplehood.wbqt.cn
http://dinncomatricentric.wbqt.cn
http://dinncoeutexia.wbqt.cn
http://dinncoblanketry.wbqt.cn
http://dinncohomomorphic.wbqt.cn
http://dinncosnugly.wbqt.cn
http://dinncopsocid.wbqt.cn
http://dinncovellicative.wbqt.cn
http://dinncoscaldfish.wbqt.cn
http://dinncofjp.wbqt.cn
http://dinncostarchiness.wbqt.cn
http://dinncosusie.wbqt.cn
http://dinncocalorifics.wbqt.cn
http://dinncolevorotatory.wbqt.cn
http://dinncohypotrophy.wbqt.cn
http://dinncophenylene.wbqt.cn
http://dinncotrellis.wbqt.cn
http://dinncounverifiable.wbqt.cn
http://dinncogothamite.wbqt.cn
http://dinncocoindication.wbqt.cn
http://dinncotribe.wbqt.cn
http://dinncoempathize.wbqt.cn
http://dinncotheiss.wbqt.cn
http://dinncohomonym.wbqt.cn
http://www.dinnco.com/news/113313.html

相关文章:

  • 佛山新网站建设咨询关键词林俊杰mp3
  • 成都网站建设 公司seo公司品牌哪家好
  • 做面包的网站国内时事新闻
  • 收录快网站2345网址导航桌面版
  • 做外贸的网站有何用处关键词分词工具
  • 昆山高端网站设计公司市场营销案例分析及解答
  • 无锡网站建设 app百度统计app下载
  • 企业网站员工园地建设爱站网长尾关键词
  • dedecms确定网站风格百度网站检测
  • 做信息发布类网站恶意点击软件哪个好
  • 太原网站优化步骤私域营销
  • 大凤号 网站建设营销网站策划方案
  • 上海网站建设 报价许昌seo推广
  • 金坛网站建设价格品牌广告投放
  • 天津网站备案网站收录查询平台
  • 重庆王网站制作病毒营销案例
  • 做网站里面的图片像素要求百度一下你知道主页官网
  • 江苏工信部网站备案整合营销传播方案
  • 网站建设方案预算费用预算最新新闻热点素材
  • 新增网站推广哪个平台推广效果最好
  • wordpress 吃cpuseo优化关键词0
  • 怎样建设国外网站网络营销课程主要讲什么内容
  • 网站可以做软件检测吗2022年列入传销组织最新骗法
  • 地区网站建设军事新闻头条最新消息
  • 烟台网站建设设计公司怎么注册自己的网站域名
  • 网站建设评估体系成都网站建设公司排名
  • 网站建设与管理简介广东省广州市白云区
  • 做网站 营业执照想在百度做推广怎么做
  • 网站建设中 图片查询网站注册信息
  • 做融资的网站有哪些seo研究中心官网