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

个人网站制作新手教程网站开发颜色

个人网站制作新手教程,网站开发颜色,网络营销的方法是什么,惠州seo关键词排名代码使用方法注意修改一下路径、验证集比例、类别名称#xff0c;其他均不需要改动#xff0c;自动划分训练集、验证集、建好全部文件夹、一键自动生成Yolo格式数据集在当前目录下#xff0c;大家可以直接修改相应的配置文件进行训练。 目录 使用方法#xff1a; 全部代码…代码使用方法注意修改一下路径、验证集比例、类别名称其他均不需要改动自动划分训练集、验证集、建好全部文件夹、一键自动生成Yolo格式数据集在当前目录下大家可以直接修改相应的配置文件进行训练。 目录 使用方法 全部代码 使用方法 全部代码 import os,random,shutilimport xml.etree.ElementTree as ET import pickle import os from os import listdir,getcwd from os.path import joindef convert(size,box):x_center(box[0]box[1])/2.0y_center(box[2]box[3])/2.0xx_center/size[0]yy_center/size[1]w(box[1]-box[0])/size[0]h(box[3]-box[2])/size[1]return (x,y,w,h)def convert_annotation(xml_file_path,save_txt_file_path,classes):xml_fileos.listdir(xml_file_path)print(xml_file)for xml_name in xml_file:print(xml_file)xml_fileos.path.join(xml_file_path,xml_name)out_txt_pathos.path.join(save_txt_file_path,xml_name.split(.)[0].txt)out_txt_fopen(out_txt_path,w)treeET.parse(xml_file)roottree.getroot()sizeroot.find(size)wint(size.find(width).text)hint(size.find(height).text)for obj in root.iter(object):difficult obj.find(difficult).textclsobj.find(name).textif cls not in classes or int(difficult)1:continuecls_idclasses.index(cls)xmlboxobj.find(bndbox)b(float(xmlbox.find(xmin).text),float(xmlbox.find(xmax).text),float(xmlbox.find(ymin).text),float(xmlbox.find(ymax).text))print(w,h,b)bbconvert((w,h),b)out_txt_f.write(str(cls_id) .join([str(a) for a in bb])\n)def moving(fileDir,tarDir,rate0.2):pathDiros.listdir(fileDir)filenumberlen(pathDir)#自定义抽取图片比例picknumberint(filenumber*rate)#按照rate比例从文件夹中取一定数量的图片samplerandom.sample(pathDir,picknumber)#随机选取picknumber数量的图片print(sample)for name in sample:shutil.move(fileDir/name,tarDir/name)returndef movelabel(file_list,file_label_train,file_label_val):for i in file_list:if i.endswith(.png) or i.endswith(.jpg):#filenamefile_label_train/i[:-4]       可以将.xml文件将.txt改成.xml文件filenamefile_label_train/i[:-4].xml       #可以改成xml文件将.txt改成.xmlif os.path.exists(filename):shutil.move(filename,file_label_val)print(处理成功)if __name____main__:设置图片路径、label路径、验证集比例、类别fileDirr./JPEGImages    #图片的路径file_label_train r./Annotations    #标签文件的路径rate0.2  #验证集的比例classes1 [fire]以下均不需要改动if not os.path.exists(./JPEGImages_val):# Create the folderos.makedirs(./JPEGImages_val)tarDirr./JPEGImages_valmoving(fileDir,tarDir,rate)file_listos.listdir(tarDir)if not os.path.exists(./Annotations_val):# Create the folderos.makedirs(./Annotations_val)file_label_valr./Annotations_valmovelabel(file_list,file_label_train,file_label_val)#VOC转Yolo格式# 2 voc 格式的xml标签文件if not os.path.exists(./val):# Create the folderos.makedirs(./val)if not os.path.exists(./train):# Create the folderos.makedirs(./train)xml_files1 r./Annotations_valsave_txt_files1 r./valconvert_annotation(xml_files1, save_txt_files1, classes1)xml_files1 r./Annotationssave_txt_files1 r./trainconvert_annotation(xml_files1, save_txt_files1, classes1)#创建所有文件夹if not os.path.exists(./images):# Create the folderos.makedirs(./images)if not os.path.exists(./labels):# Create the folderos.makedirs(./labels)#将所有文件移动到最终的文件夹中import shutil# Define the source and destination folderssource_folder ./traindestination_folder ./labels# Move the files from the source folder to the destination foldershutil.move(source_folder, destination_folder)source_folder ./valdestination_folder ./labels# Move the files from the source folder to the destination foldershutil.move(source_folder, destination_folder)source_folder ./JPEGImagesdestination_folder ./images# Move the files from the source folder to the destination foldershutil.move(source_folder, destination_folder)os.rename(./images/JPEGImages, ./images/train)source_folder ./JPEGImages_valdestination_folder ./images# Move the files from the source folder to the destination foldershutil.move(source_folder, destination_folder)os.rename(./images/JPEGImages_val, ./images/val)
http://www.huolong8.cn/news/136785/

相关文章:

  • 网站建设征求意见表服务哪家好中医小程序定制
  • 河南省建筑网官网品牌seo是什么意思
  • 自己做电商网站万网 网站空间
  • 川畅联系 做网站多少钱在线网站代码生成器
  • 有赞做网站地产网站开发公司
  • 百度开放云做网站网站建设包括哪些方面
  • 定制网站成本多少中国建设官方网站首页
  • 济南百度网站开发常州网站建设推荐
  • 江苏建设外贸公司网站做类似电影天堂的网站违法吗
  • 湖南做防水堵漏工程商网站广告推广话术
  • 怎么上不到建设银行网站广州网站建设app开发
  • 专业网站建设设计公司娱乐网站设计SEO
  • 个人网站如何做移动端三亚网红餐厅
  • 武威网站建设价格福州自适应网站建设
  • 内江网站建设免费网站地址申请
  • 东莞网站建设营销哪家好什么网站可以做问卷调查
  • 如何制作简单的网站手机平板购物网站的设计背景
  • 如何做网站 做论坛域名搭建网站
  • 有哪些做ppt用图片的网站有哪些百度网站抓取
  • 网站后缀 .cgi企业网站管理系统视频教程
  • 丽水企业网站建设莲塘网站建设
  • it网站开发百度首页广告
  • 精品课程网站设计报告12580黄页推广
  • 网站设计这个专业怎么样网络科技公司骗术
  • 品牌设计网站大全网站建设费摊多久
  • 网推公司怎么收费荥阳网站优化公司
  • 商会网站建设方案书教育网站的开发与建设论文
  • 中信建设有限责任公司电话号码手机网站优化怎么做
  • 梦扬科技 合肥网站建设杭州做网站软件
  • 网站站长英语电商网站开发主要技术问题