wordpress 站点转移,怎么才能百度做网站,网站备案 做网站时就需要吗,页面设计在哪打开Anylabel可以极大的增加数据的标注效率#xff0c;但是其标注格式如何能转换成YOLO标注格式#xff0c;具体内容如下所示。 关于AnyLabeling的其它详细介绍如下链接所示 https://blog.csdn.net/u011775793/article/details/134918861 Github链接 https://github.com/vietanhd…Anylabel可以极大的增加数据的标注效率但是其标注格式如何能转换成YOLO标注格式具体内容如下所示。 关于AnyLabeling的其它详细介绍如下链接所示 https://blog.csdn.net/u011775793/article/details/134918861 Github链接 https://github.com/vietanhdev/anylabeling python代码 import json
import osdef labelme_to_yolo(label_me_json_file, cls2id_dict):label_me_json json.load(open(label_me_json_file, moder, encodingUTF-8))shapes label_me_json[shapes]img_width, img_height label_me_json[imageWidth], label_me_json[imageHeight]img_path label_me_json[imagePath]img_data label_me_json[imageData] if imageData in label_me_json else labels []for s in shapes:s_type s[shape_type]s_type s_type.lower()if s_type rectangle:pts s[points]x1, y1 pts[0] # left cornerx2, y2 pts[1] # right cornerx (x1 x2) / 2 / img_widthy (y1 y2) / 2 / img_heightw abs(x2 - x1) / img_widthh abs(y2 - y1) / img_heightcid cls2id_dict[s[label]]labels.append(f{cid} {x} {y} {w} {h})return labelsdef write_label2txt(save_txt_path,label_list):fopen(save_txt_path,w,encodingUTF-8)for label in label_list:temp_listlabel.split( )f.write(temp_list[0])f.write( )f.write(temp_list[1])f.write( )f.write(temp_list[2])f.write( )f.write(temp_list[3])f.write( )f.write(temp_list[4])f.write(\n)if __name__ __main__:# 原始图片文件夹路径img_dirrD:\desk\Work\Dataset\Test\Test_Anylabeling\imgs# 原始JSON标签文件夹路径json_dirrD:\desk\Work\Dataset\Test\Test_Anylabeling\labels# 生成保存TXT文件夹路径save_dirrD:\desk\Work\Dataset\Test\Test_Anylabeling\txt# 类别和序号的映射字典cls2id_dict{building1:0}if not os.path.exists(save_dir):os.makedirs(save_dir)for json_name in os.listdir(json_dir):json_pathos.path.join(json_dir,json_name)txt_namejson_name.split(.)[0].txtsave_txt_pathos.path.join(save_dir,txt_name)labels labelme_to_yolo(json_path,cls2id_dict)write_label2txt(save_txt_path,labels)
具体修改 # 原始图片文件夹路径
img_dirrD:\desk\Work\Dataset\Test\Test_Anylabeling\imgs 改为自己的图片路径 # 原始JSON标签文件夹路径
json_dirrD:\desk\Work\Dataset\Test\Test_Anylabeling\labels 改为自己的JSON文件夹路径 # 生成保存TXT文件夹路径
save_dirrD:\desk\Work\Dataset\Test\Test_Anylabeling\txt 改为自己的保存生成的yolo文件夹路径 # 类别和序号的映射字典
cls2id_dict{building1:0} 改为自己的标签映射 开始实验
实验准备 运行代码 实验验证
实验验证可视化代码相关链接 https://blog.csdn.net/weixin_49824703/article/details/134050547 完美