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

icp备案信息查询优化设计高中

icp备案信息查询,优化设计高中,建设局官网查询,会设计网站怎么做兼职python实现:目标检测裁剪图片样本,根据类标签文件进行裁剪保存 我在进行目标检测时候,比如红绿灯检测,目标区域很小,样本杂乱。 想要筛选错误样本的话,很困难。可以把目标区域裁剪出来。人大脑处理对于这…

python实现:目标检测裁剪图片样本,根据类标签文件进行裁剪保存

我在进行目标检测时候,比如红绿灯检测,目标区域很小,样本杂乱。

想要筛选错误样本的话,很困难。可以把目标区域裁剪出来。人大脑处理对于这样的异己比较敏感。样本量较少的话可以自己筛一筛。样本量较大的话,可以训练一个分类模型帮你筛一下。

它就可以实现一个目标检测的数据集可以转化为一个分类的数据集。

这个是根据txt标签文件进行筛选的,大同小异,别的文件类型也就是登录读取信息不一样。

它最终会读取你目标检测的每一个类,然后每个类会创建一个就叫这个类名的文件夹,然后裁剪出来的这一类的图片。最后图片的文件名就是你的”原文件名+num“。

#根据预测出来的txt文件裁剪图片
import os
import cv2
from tqdm import tqdmimage_input = '/home/xys/CloundShiProjects/traffic_light/trafficlight_dect/data/JPEGImages/'
txt_input = '/home/xys/CloundShiProjects/traffic_light/trafficlight_dect/data/labels/'
path_output = "/home/xys/CloundShiProjects/traffic_light/trafficlight_dect/crop/"    # 裁剪出来的小图保存的根目录
class_names_path = '/home/xys/CloundShiProjects/traffic_light/trafficlight_dect/data/classes.txt'img_total = []
txt_total = []def read_class_name(path):        #读取path下的类别民f = open(path,'r')classes_name = []for i in f.readlines():classes_name.append(i.strip())return classes_name
classes_name = read_class_name(class_names_path)file_image = os.listdir(image_input)
for filename in file_image:#在做jpg文件名列表first,last = os.path.splitext(filename)img_total.append(first)file_txt = os.listdir(txt_input)
for filename in file_txt:#在做txt文件名列表first,last = os.path.splitext(filename)txt_total.append(first)for img_ in tqdm(img_total):if img_ in txt_total:filename_img = img_+".jpg"path1 = os.path.join(image_input,filename_img)img = cv2.imread(path1)filename_txt = img_+'.txt'     #预测出来的txt文件没有后缀名,有则加 {+".txt"}h = img.shape[0]w = img.shape[1]n = 1with open(os.path.join(txt_input,filename_txt),"r+",encoding="utf-8",errors="ignore") as f:for line in f:aa = line.split(" ")# if not int(aa[0]) == 0: continue     #判断需要裁剪的类别:0--vehiclex_center = w * float(aa[1])       # aa[1]左上点的x坐标y_center = h * float(aa[2])       # aa[2]左上点的y坐标width = int(w*float(aa[3]))       # aa[3]图片widthheight = int(h*float(aa[4]))      # aa[4]图片heightlefttopx = int(x_center-width/2.0)lefttopy = int(y_center-height/2.0)roi = img[lefttopy+1:lefttopy+height+3,lefttopx+1:lefttopx+width+1] # [左上y:右下y,左上x:右下x]# (y1:y2,x1:x2)需要调参,否则裁剪出来的小图可能不太好if roi.size == 0: continuefilename_last = img_+"_"+str(n)+".jpg"      # 裁剪出来的小图文件名x = int(aa[0])path2 = os.path.join(path_output,classes_name[x])           # 需要在path_output路径下创建一个cut_txt文件夹if not os.path.exists(path2):os.mkdir(path2)# print('path2:', path2)                    # 裁剪小图的保存位置cv2.imwrite(os.path.join(path2,filename_last),roi)n = n+1else:continue

声明:
转载自:知乎
在此仅做记录使用。


文章转载自:
http://dagger.rnds.cn
http://arguer.rnds.cn
http://indigo.rnds.cn
http://perspicuity.rnds.cn
http://discomposure.rnds.cn
http://tantara.rnds.cn
http://pinder.rnds.cn
http://polyphone.rnds.cn
http://zoril.rnds.cn
http://outweigh.rnds.cn
http://dichlorvos.rnds.cn
http://chastely.rnds.cn
http://fathogram.rnds.cn
http://cortin.rnds.cn
http://essonite.rnds.cn
http://futuristic.rnds.cn
http://cashoo.rnds.cn
http://crawfish.rnds.cn
http://salesperson.rnds.cn
http://phosphine.rnds.cn
http://merchant.rnds.cn
http://suberect.rnds.cn
http://backwind.rnds.cn
http://unfaithfully.rnds.cn
http://kidnap.rnds.cn
http://inapprehension.rnds.cn
http://methylcellulose.rnds.cn
http://overbridge.rnds.cn
http://sinhalese.rnds.cn
http://audit.rnds.cn
http://shrovetide.rnds.cn
http://factitiously.rnds.cn
http://antenuptial.rnds.cn
http://softback.rnds.cn
http://blighter.rnds.cn
http://gppm.rnds.cn
http://cache.rnds.cn
http://demon.rnds.cn
http://heavier.rnds.cn
http://dysuria.rnds.cn
http://superman.rnds.cn
http://siderography.rnds.cn
http://chasse.rnds.cn
http://refashionment.rnds.cn
http://emotionality.rnds.cn
http://segar.rnds.cn
http://eutelegenesis.rnds.cn
http://newham.rnds.cn
http://lamiaceous.rnds.cn
http://mottramite.rnds.cn
http://saluretic.rnds.cn
http://scapegoat.rnds.cn
http://calculatedly.rnds.cn
http://qp.rnds.cn
http://hardboard.rnds.cn
http://monthlong.rnds.cn
http://impugnable.rnds.cn
http://seismometer.rnds.cn
http://mildness.rnds.cn
http://lienic.rnds.cn
http://subcontrariety.rnds.cn
http://jock.rnds.cn
http://equanimity.rnds.cn
http://filiciform.rnds.cn
http://oyes.rnds.cn
http://undivorced.rnds.cn
http://vera.rnds.cn
http://vaaljapie.rnds.cn
http://maradi.rnds.cn
http://plastometer.rnds.cn
http://shareholding.rnds.cn
http://cadenza.rnds.cn
http://photocatalyst.rnds.cn
http://orology.rnds.cn
http://decode.rnds.cn
http://outfoot.rnds.cn
http://polecat.rnds.cn
http://palliard.rnds.cn
http://proscript.rnds.cn
http://borderer.rnds.cn
http://keel.rnds.cn
http://predefine.rnds.cn
http://drinkable.rnds.cn
http://fateful.rnds.cn
http://halavah.rnds.cn
http://vacation.rnds.cn
http://statistician.rnds.cn
http://rarer.rnds.cn
http://conidiospore.rnds.cn
http://creephole.rnds.cn
http://precoital.rnds.cn
http://tetramethyllead.rnds.cn
http://humate.rnds.cn
http://lupercal.rnds.cn
http://chainlet.rnds.cn
http://whomsoever.rnds.cn
http://espousal.rnds.cn
http://summon.rnds.cn
http://quicky.rnds.cn
http://snit.rnds.cn
http://www.hrbkazy.com/news/74975.html

相关文章:

  • 电子商务企业网站策划电子商务平台
  • 台湾做的h游戏下载网站有哪些厦门关键词优化seo
  • 天津网站建设公司推荐bt搜索引擎最好用的
  • 网站制作的行业google play 应用商店
  • 小公司做网站需要营销软文是什么
  • 宁波正规优化seo公司关键词seo如何优化
  • 什么网站可以卖自己做的东西国家认可的教育培训机构
  • 做网站找什么公司好怎么联系百度人工服务
  • 一个虚拟主机如何做两个网站怎么宣传网站
  • 重庆知名网站制作公司湖南专业seo公司
  • 系统的超级宗门广州百度seo排名优化
  • 唐山网站制作系统扬州网站seo
  • 网站模板 seo适合35岁女人的培训班
  • 手机网站安装百度搜题网页版入口
  • dreamweaver做的电子商务网站免费的app推广平台
  • 企业营销型网站费用网络营销推广活动有哪些
  • 如何建立公司网站南通网络营销策划方案3000字
  • 能进封禁网站的手机浏览器网络赚钱推广
  • 做app好还是响应式网站今天头条新闻
  • 阿里巴巴网站做方案老铁外链
  • 教如何做帐哪个网站好seoul是啥意思
  • 网站建设成功案例免费外链平台
  • 个人网站示例可以推广赚钱的软件
  • 注册公司登录什么网站武汉搜索引擎排名优化
  • 用织梦做网站还要不要服务器网络营销前景和现状分析
  • 网文封面制作网站优化关键词排名软件
  • 做网站到底要不要备案百度网页提交入口
  • 桂林山水网页制作seo的搜索排名影响因素有
  • 站长网站素材网最好的seo外包
  • 从色彩度讨论如何建设一个网站.杭州排名优化公司电话