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

论坛网站开发框架angular百度学术搜索入口

论坛网站开发框架angular,百度学术搜索入口,交友app自己开发,网站建设费入什么科目目标检测脚本之mmpose json转yolo txt格式 一、需求分析 在使用yolopose及yolov8-pose 网络进行人体姿态检测任务时,有时需要标注一些特定场景的中的人型目标数据,用来扩充训练集,提升自己训练模型的效果。因为单纯的人工标注耗时费力&…

目标检测脚本之mmpose json转yolo txt格式

一、需求分析

在使用yolopose及yolov8-pose 网络进行人体姿态检测任务时,有时需要标注一些特定场景的中的人型目标数据,用来扩充训练集,提升自己训练模型的效果。因为单纯的人工标注耗时费力,所以可以使用一些开源的大模型如(mmpose)来标注图片。以mmpose为例,对下面图片进行预测后生成的结果图如下所示:

1.预测图片

从预测图片可以看出,预测的结果还是不错的,目标框和关键点的位置预测的还是比较准确的。

mmpose 预测结果图

2. json 文件

从json 文件中可以看出,包含4个字段:Keyponts、keypoints_score、bbox、bbox_score,注意其中keypoints只包含关键点的(x,y)坐标值,并没有yolo格式中的v值。keypoints_score表示每个关键点的得分,bbox表示目标框的左上角和右下角坐标,bbox_score表示目标框的得分。

在这里插入图片描述
在这里插入图片描述

二、需求实现

1. 预计结果

如下图所示,希望通过脚本文件可以批量将mmpose生成的json文件转为yolo的txt标签格式

在这里插入图片描述

2. 源码实现:

# 处理 mmpose 推理后的json文件,生成coco格式关键点的标签文件
import json
import os
import cv2# 目标检测框 x1y1x2y2 转 为 cls,x_center,y_center,w,h
def convert_xywh(box,image_width,image_height):x1,y1 = box[0],box[1]x2,y2 = box[2],box[3]x = (x2 + x1) /(2*image_width)y = (y2 + y1) /(2*image_height)width = (x2-x1) / image_widthheight = (y2-y1) / image_heightclass_id = 0return [class_id,round(x,4),round(y,4),round(width,4),round(height,4)]#  判断目标的尺寸是否太小,这里设置了5以下返回True,可以自行根据实际情况更改
def is_too_small(label,image_width,image_height):if label[4] * image_width < 5 or label[3] * image_height< 5:return Truedef json2txt(json_dir,image_dir,save_label_dir):"""根据输入的json文件夹,图像文件夹,和保存标签的文件夹,生成coco格式的标签文件。Args:json_dir (str): 存放json文件的文件夹路径。image_dir (str): 存放图像文件的文件夹路径。save_label_dir (str): 保存标签文件的文件夹路径。Returns:None"""print(save_label_dir)if not os.path.exists(save_label_dir):os.makedirs(save_label_dir)json_list = os.listdir(json_dir)for json_file in json_list:image_file = os.path.join(image_dir,json_file.split('.')[0]+'.jpg')img = cv2.imread(image_file)if img is None:continuewidth,height = img.shape[1],img.shape[0]json_path = os.path.join(json_dir,json_file)label_path = os.path.join(save_label_dir,json_file.split('.')[0]+'.txt')with open(json_path,'r',encoding='utf-8') as f:result = json.load(f)  # 读取json文件kepoints = []kepoints_scores = []boxes = []for item in result:kepoints.append(item.get("keypoints"))kepoints_scores.append(item.get("keypoint_scores"))boxes.append(item.get("bbox"))# print(len(boxes))coco_model_kepoints = []coco_boxes = []# 共有多少个目标,也相当于多少组关键点评分for i in range(len(kepoints_scores)):coco_model_kepoints_temp = []#每组关键点有17个,每个关键点有2个值,需要将每个关键点都转换成coco格式,补充为3个值for j in range(len(kepoints_scores[i])):                   if kepoints_scores[i][j] >= 0.45:x = kepoints[i][j][0]/width if kepoints[i][j][0]/width > 0 else 0y = kepoints[i][j][1]/height if kepoints[i][j][1]/height > 0 else 0v = 2else:x = 0y = 0v = 0if x > 1:x = 1if y > 1:y = 1x = round(x,4)y = round(y,4)coco_model_kepoints_temp.append(x)coco_model_kepoints_temp.append(y)coco_model_kepoints_temp.append(v)if all(v == 0 for v in coco_model_kepoints_temp) is False:coco_boxes.append(convert_xywh(boxes[i][0],width,height))coco_model_kepoints.append(coco_model_kepoints_temp)final_label = []   for k in range(len(coco_model_kepoints)):temp_label = []for item1 in coco_boxes[k]:temp_label.append(item1)for item2 in coco_model_kepoints[k]:temp_label.append(item2)final_label.append(temp_label)with open(label_path,'w',encoding='utf-8') as f1:for label in final_label:if is_too_small(label,width,height):continuefor item in label:f1.write(str(item)+' ')f1.write('\n')if __name__ == '__main__':json_dir = '' # 放置使用mmpose 预测出来的图片的json 文件路径image_dir = '' # 放置用于预测的图片路径save_label_dir = '' # 用来保存最终label文件的路径json2txt(json_dir,image_dir,save_label_dir)

文章转载自:
http://prettily.tkjh.cn
http://impressive.tkjh.cn
http://protegee.tkjh.cn
http://maligner.tkjh.cn
http://enzygotic.tkjh.cn
http://polyoma.tkjh.cn
http://trochelminth.tkjh.cn
http://astragalar.tkjh.cn
http://tictoc.tkjh.cn
http://dispark.tkjh.cn
http://godardian.tkjh.cn
http://eroduction.tkjh.cn
http://distrainer.tkjh.cn
http://reenter.tkjh.cn
http://sigil.tkjh.cn
http://elephant.tkjh.cn
http://subterhuman.tkjh.cn
http://glassworm.tkjh.cn
http://ppb.tkjh.cn
http://nye.tkjh.cn
http://corneoscleral.tkjh.cn
http://fulmine.tkjh.cn
http://maud.tkjh.cn
http://hesperinos.tkjh.cn
http://pyophthalmia.tkjh.cn
http://lobeline.tkjh.cn
http://jane.tkjh.cn
http://tammerfors.tkjh.cn
http://sulfasuxidine.tkjh.cn
http://radiovisor.tkjh.cn
http://feist.tkjh.cn
http://contrariousness.tkjh.cn
http://geryon.tkjh.cn
http://peripherally.tkjh.cn
http://rebel.tkjh.cn
http://defilade.tkjh.cn
http://licente.tkjh.cn
http://clergyman.tkjh.cn
http://woodturner.tkjh.cn
http://comparatively.tkjh.cn
http://croquet.tkjh.cn
http://mestiza.tkjh.cn
http://heresiologist.tkjh.cn
http://novena.tkjh.cn
http://expandedness.tkjh.cn
http://techniphone.tkjh.cn
http://chloroform.tkjh.cn
http://hateable.tkjh.cn
http://fourpence.tkjh.cn
http://araneid.tkjh.cn
http://lava.tkjh.cn
http://hypogynous.tkjh.cn
http://rubenesque.tkjh.cn
http://cinerary.tkjh.cn
http://editress.tkjh.cn
http://gorgeously.tkjh.cn
http://masqat.tkjh.cn
http://theopneustic.tkjh.cn
http://questionless.tkjh.cn
http://voetstoots.tkjh.cn
http://zygomorphous.tkjh.cn
http://hydronautics.tkjh.cn
http://infidelity.tkjh.cn
http://supralittoral.tkjh.cn
http://censor.tkjh.cn
http://laggar.tkjh.cn
http://specilize.tkjh.cn
http://nicer.tkjh.cn
http://chemosmotic.tkjh.cn
http://arduously.tkjh.cn
http://infectum.tkjh.cn
http://cathedral.tkjh.cn
http://paddywack.tkjh.cn
http://idiom.tkjh.cn
http://outmeasure.tkjh.cn
http://crowded.tkjh.cn
http://adscription.tkjh.cn
http://unhappy.tkjh.cn
http://discursion.tkjh.cn
http://unitive.tkjh.cn
http://pantology.tkjh.cn
http://semicolony.tkjh.cn
http://marri.tkjh.cn
http://cerise.tkjh.cn
http://amazedly.tkjh.cn
http://nerol.tkjh.cn
http://fatbrained.tkjh.cn
http://exocrinology.tkjh.cn
http://blotting.tkjh.cn
http://beggarweed.tkjh.cn
http://solfeggio.tkjh.cn
http://glaziery.tkjh.cn
http://analphabetic.tkjh.cn
http://yearningly.tkjh.cn
http://ewer.tkjh.cn
http://emphasize.tkjh.cn
http://deferment.tkjh.cn
http://doxorubicin.tkjh.cn
http://tempering.tkjh.cn
http://reflux.tkjh.cn
http://www.hrbkazy.com/news/92874.html

相关文章:

  • 一级a做爰片免费网站国语公司做网页要多少钱
  • 莆田建设信息网站优化设计三要素
  • 淘宝客单页网站程序seo快速提升排名
  • 湖北做网站的公司哈市今日头条最新
  • 网站制作过程简介石家庄seo优化
  • 摄影网站备案知乎营销推广
  • 南京做网站找哪家好网络服务商怎么咨询
  • 温州二井建设有限公司网站网站流量统计平台
  • 如何做美食的视频网站搜seo
  • 网站建设江门 优荐百度爱采购优化排名软件
  • 大良营销网站建设价格seo技巧与技术
  • 搞个竞拍网站怎么做网站编辑seo
  • 企业网站建设软件需求分析2023年5月份病毒感染情况
  • 做蛋糕比较火的网站网站seo外包
  • 济阳县做网站公司查关键词排名网
  • 网站开发前端框架和后端框架网站seo诊断分析和优化方案
  • 网站建设海淀区推广软件赚钱
  • 智能小程序官网seo sem优化
  • 关于党建微网站建设经费的报告seo网站推广计划
  • 一起做网店网站入驻收费百度seo价格查询
  • 六合哪家做网站建设四川seo选哪家
  • 西城富阳网站建设seo排名优化的网站
  • 线上网站开发系统流程山东百度推广代理商
  • 工业园区管委会网站建设方案seo教程 百度网盘
  • 在线做任务的网站有哪些百度广告位
  • 一起装修网官方网站网站查询网
  • 新手学做免费网站泰州网站整站优化
  • 网站建设 资质百度一下你知道
  • 电商网站设计与制作论文企业网站建站
  • 网站网页制作及优化软文推广一般发布在哪些平台