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

公司邮箱格式广州网站优化注意事项

公司邮箱格式,广州网站优化注意事项,什么外贸网站做箱包好,wordpress中文官网地址接上篇#xff0c;根据脚本可将coco128的128张图片#xff0c;按照比例划分成训练集、测试集、验证集#xff0c;同时生成相应的标注的labels文件夹#xff0c;最近再看实例分离比较火的mask rcnn模型#xff0c;准备进行调试但由于实验室算力不足#xff0c;网上自己租的…接上篇根据脚本可将coco128的128张图片按照比例划分成训练集、测试集、验证集同时生成相应的标注的labels文件夹最近再看实例分离比较火的mask rcnn模型准备进行调试但由于实验室算力不足网上自己租的2080ti马传整个coco2017实在是太慢了检索了一下没有开源的部分coco2017数据集于是我想到将coco128的数据转化成json文件便于新手进行debug节约时间和算力。 数据集结构准备如上在我上篇博文的基础上新增classes.txt文件和annotations文件夹 脚本如下 import os import json import cv2 import random import time from PIL import Imagecoco_format_save_path/root/autodl-tmp/deep-learning-for-image-processing-master/pytorch_object_detection/mask_rcnn/data/annotations/ #要生成的标准coco格式标签所在文件夹 yolo_format_classes_path/root/autodl-tmp/deep-learning-for-image-processing-master/pytorch_object_detection/mask_rcnn/data/train/classes.txt #类别文件一行一个类 yolo_format_annotation_path/root/autodl-tmp/deep-learning-for-image-processing-master/pytorch_object_detection/mask_rcnn/data/train/labels/ #yolo格式标签所在文件夹 img_pathDir/root/autodl-tmp/deep-learning-for-image-processing-master/pytorch_object_detection/mask_rcnn/data/train/images/ #图片所在文件夹with open(yolo_format_classes_path,r) as fr: #打开并读取类别文件lines1fr.readlines() # print(lines1) categories[] #存储类别的列表 for j,label in enumerate(lines1):labellabel.strip()categories.append({id:j1,name:label,supercategory:None}) #将类别信息添加到categories中 # print(categories)write_json_contextdict() #写入.json文件的大字典 write_json_context[info] {description: , url: , version: , year: 2024, contributor: 纯粹ss, date_created: 2024-01-12} write_json_context[licenses][{id:1,name:None,url:None}] write_json_context[categories]categories write_json_context[images][] write_json_context[annotations][]#接下来的代码主要添加images和annotations的key值 imageFileListos.listdir(img_pathDir) #遍历该文件夹下的所有文件并将所有文件名添加到列表中 for i,imageFile in enumerate(imageFileList):imagePath os.path.join(img_pathDir,imageFile) #获取图片的绝对路径image Image.open(imagePath) #读取图片然后获取图片的宽和高W, H image.sizeimg_context{} #使用一个字典存储该图片信息#img_nameos.path.basename(imagePath) #返回path最后的文件名。如果path以/或\结尾那么就会返回空值img_context[file_name]imageFileimg_context[height]Himg_context[width]Wimg_context[date_captured]2024.1.12img_context[id]i #该图片的idimg_context[license]1img_context[color_url]img_context[flickr_url]write_json_context[images].append(img_context) #将该图片信息添加到image列表中txtFileimageFile[:12].txt #获取该图片获取的txt文件with open(os.path.join(yolo_format_annotation_path,txtFile),r) as fr:linesfr.readlines() #读取txt文件的每一行数据lines2是一个列表包含了一个图片的所有标注信息for j,line in enumerate(lines):bbox_dict {} #将每一个bounding box信息存储在该字典中# line line.strip().split()# print(line.strip().split( ))class_id,x,y,w,hline.strip().split( ) #获取每一个标注框的详细信息class_id,x, y, w, h int(class_id), float(x), float(y), float(w), float(h) #将字符串类型转为可计算的int和float类型xmin(x-w/2)*W #坐标转换ymin(y-h/2)*Hxmax(xw/2)*Wymax(yh/2)*Hww*Whh*Hbbox_dict[id]i*10000j #bounding box的坐标信息bbox_dict[image_id]ibbox_dict[category_id]class_id1 #注意目标类别要加一bbox_dict[iscrowd]0height,widthabs(ymax-ymin),abs(xmax-xmin)bbox_dict[area]height*widthbbox_dict[bbox][xmin,ymin,w,h]bbox_dict[segmentation][[xmin,ymin,xmax,ymin,xmax,ymax,xmin,ymax]]write_json_context[annotations].append(bbox_dict) #将每一个由字典存储的bounding box信息添加到annotations列表中name os.path.join(coco_format_save_path,train .json) with open(name,w) as fw: #将字典信息写入.json文件中json.dump(write_json_context,fw,indent2) 注意这里要新建classes.txt文件夹每一行表示一个物体类别编号与yolo格式的标注txt文件对应我新建的coco数据集的classes.txt文件夹如下 person bicycle car motorcycle airplane bus train truck boat traffic light fire hydrant stop sign parking meter bench bird cat dog horse sheep cow elephant bear zebra giraffe backpack umbrella hangbag tie suitcase frisbee skis snowboard sports ball kite baseball bat baseball glove skateboard surfboard tennis racket bottle wine glass cup fork knife spoon bowl banana apple sandwich orange broccoli carrot hot dog pizza donut cake chair couch potted plant bed mirror dining table window desk toilet door tv laptop mouse remote keyboard cell phone microwave oven toaster sink refrigerator blender book clock(txt文件发出来是因为查了一下发现网上给出的coco类别与编码都是图片由于自己手欠还打了两遍发出来大家可以直接用 注意脚本运行时候的一些设置 脚本关于获取图片对应txt文件时需要名字对应我是编号为000000000009.txt,因此这里设置的是12表示前12位感觉也可以用文件名末尾.jpg替换为.txt来实现。 最后生成的coco格式的json文件如下 {info: {description: ,url: ,version: ,year: 2024,contributor: \u7eaf\u7cb9ss,date_created: 2024-01-12},licenses: [{id: 1,name: null,url: null}],categories: [{id: 1,name: person,supercategory: None},{id: 2,name: bicycle,supercategory: None},.....images: [{file_name: 000000000030.jpg,height: 428,width: 640,date_captured: 2024.1.12,id: 0,license: 1,color_url: ,flickr_url: },.......annotations: [{id: 0,image_id: 0,category_id: 59,iscrowd: 0,area: 82611.7361856,bbox: [204.86016,31.019727999999994,254.88,324.12012],segmentation: [[204.86016,31.019727999999994,459.74016,31.019727999999994,459.74016,355.13984800000003,204.86016,355.13984800000003]]},{id: 1,image_id: 0,category_id: 76,iscrowd: 0,area: 32489.62928639999,bbox: [237.56032,155.80997600000003,166.4,195.25017599999998],segmentation: [[237.56032,155.80997600000003,403.96031999999997,155.80997600000003,403.96031999999997,351.060152,237.56032,351.060152]]},{生成json文件后可以用脚本来测试这里借用博主太阳花的小绿豆的脚本 import os from pycocotools.coco import COCO from PIL import Image, ImageDraw import matplotlib.pyplot as pltjson_path /root/autodl-tmp/deep-learning-for-image-processing-master/pytorch_object_detection/mask_rcnn/data/annotations/train.json img_path /root/autodl-tmp/deep-learning-for-image-processing-master/pytorch_object_detection/mask_rcnn/data/train/images# load coco data coco COCO(annotation_filejson_path)# get all image index info ids list(sorted(coco.imgs.keys())) print(number of images: {}.format(len(ids)))# get all coco class labels coco_classes dict([(v[id], v[name]) for k, v in coco.cats.items()])# 遍历前三张图像 for img_id in ids[:20]:# 获取对应图像id的所有annotations idx信息ann_ids coco.getAnnIds(imgIdsimg_id)# 根据annotations idx信息获取所有标注信息targets coco.loadAnns(ann_ids)# get image file namepath coco.loadImgs(img_id)[0][file_name]# read imageimg Image.open(os.path.join(img_path, path)).convert(RGB)draw ImageDraw.Draw(img)# draw box to imagefor target in targets:x, y, w, h target[bbox]x1, y1, x2, y2 x, y, int(x w), int(y h)draw.rectangle((x1, y1, x2, y2))draw.text((x1, y1), coco_classes[target[category_id]])# show imageplt.imshow(img)plt.show() 可以可视化数据集图片的标注结果 说明我们生成的json文件是正确的
http://www.pierceye.com/news/563343/

相关文章:

  • 运动器材网站开发方案失信被执行人名单查询系统
  • 深圳商业网站建设模板网站建设worldpress
  • 宁波网站排名网站开发 哪家好
  • 做网站的软件工程师网站积分程序怎么建设
  • ps网站轮播图怎么做动漫制作专业的来源
  • 怎么知道一个网站是谁做的建筑认证
  • 网站关键词优化排名公司网站备案的意思
  • 怎么把qq空间做成企业网站医疗网站设计
  • 个人博客网站需求分析上海最大企业前十名
  • 兴义之窗网站怎么做网页界面设计的类别
  • 黄南州网站建设公司安徽省建设厅执业资格注册中心网站
  • wordpress布置网站教程wordpress it模板下载地址
  • 网站首页栏目设置宿州建设网站公司哪家好
  • 西安网站建设怎么接单做社交的招聘网站
  • 实训课网站开发个人小结横岗做网站
  • 网站集约化建设管理方案wordpress加cnzz统计在那里加
  • 重庆知道推广网站方法青岛网络推广的有哪些公司
  • 自己做网站服务器要多少钱特殊字体
  • 网站建设合同 协议书网站建设工具有哪些
  • 网站建设的基本条件网站建设策划案怎么写
  • 知乎网站开发用的语言郑州建设网站哪家好
  • 企业官网建站费用长沙做无痛肠镜东大医院l网站
  • 建网站资料wordpress 读书模板
  • 网站建设初学者教程成华区微信网站建设公司
  • 沈阳网站建设-中国互联商城页面
  • 成交型网站倡导公司进贤南昌网站建设公司
  • 网站跟软件有什么区别是什么点击器原理
  • 网站建设项目策划书范文杭州 网站开发公司
  • 酒店网站建设设计企业营销型网站策划
  • 用dw怎么做登录页面的网站成都微信网站建设推