当前位置: 首页 > 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.sadfv.cn/news/136785/

相关文章:

  • 网站建设方案及教育集团网站建设
  • 外贸网站建设szjijie政务公开 加强门户网站建设
  • 网站开发无使用期限怎么摊销网站栏目类型
  • 手机端视频网站模板交通信用网站建设
  • 重庆企业网站推广服务做网站新闻移动动态
  • 哪里可以做网站平台wordpress 上传图片错误
  • 电脑突然多了windows优化大师柳州专业网站优化
  • 网站流量如何提高优秀的网站通过什么提供信息
  • 学信网 的企业网站给你做认证营口市网站建设
  • 门户网站开发需要泉州app制作
  • 扬州做网站公司ppt做的好的网站
  • 透明网站模板ipsw 是谁做的网站
  • php网站容量最好用的cms
  • 广州市住房和城乡建设部网站做照片的网站有哪些软件
  • 企业网站建设要多少钱广州市手机网站建设
  • 现在建网站做推广能赚钱吗网站需要多大宽带
  • 东莞品牌网站建设费用合肥论坛网站建设
  • 一个公司做网站需要注意什么条件北京网站设计技术乐云seo
  • 广东网站设计长沙哪家网络公司做网站好
  • 如何创建网站站点并且避免广告云服务器搭建网站
  • 网站建设 九艾做网站用什么笔记本配置
  • 建设银行申请信用卡网站周村网站制作哪家好
  • 建设银行企业银行网站打不开合肥做网站的软件公司
  • wordpress页面回收站位置长沙seo在哪
  • 网站开发雇佣平台百度网页制作html
  • html5 购物网站事业单位网站登录模板
  • 汽车网站制作策划方案公司网站建设费属于什么费用
  • 咸阳网站建设公司哪家好wordpress 不收录设置
  • 网站建设首页面成都百度推广优化创意
  • app开发哪个公司专业网站seo源码