作者:同济子豪兄
labelme2coco-keypoint
labelme2coco-detection
labelme2yolo-detection
labelme2yolo-segmentation
labelme2yolo-keypoint
Labelme转mask图-语义分割
pascalvoc2yolo-detection
常见计算机视觉标注格式相互转换
作者:同济子豪兄
labelme2coco-keypoint
labelme2coco-detection
labelme2yolo-detection
labelme2yolo-segmentation
labelme2yolo-keypoint
Labelme转mask图-语义分割
pascalvoc2yolo-detection
子豪兄您好,您的labelme转coco数据集代码“【D】Labelme转COCO-批量.ipynb”中有如下部分
`def process_single_json(labelme, image_id=1):
global ANN_ID
coco_annotations = []
for each_ann in labelme['shapes']: # 遍历该json文件中的所有标注
if each_ann['shape_type'] == 'rectangle': # 筛选出框
## 该框的元数据
bbox_dict = {}
# 该框的类别 信息
bbox_dict['category_id'] = label2id[each_ann['label']]
bbox_dict['segmentation'] = []
bbox_dict['iscrowd'] = 0
bbox_dict['image_id'] = image_id
bbox_dict['id'] = ANN_ID
ANN_ID += 1
# 获取框坐标
bbox_left_top_x = min(int(each_ann['points'][0][0]), int(each_ann['points'][1][0]))
bbox_left_top_y = min(int(each_ann['points'][0][1]), int(each_ann['points'][1][1]))
bbox_right_bottom_x = max(int(each_ann['points'][0][0]), int(each_ann['points'][1][0]))
bbox_right_bottom_y = max(int(each_ann['points'][0][1]), int(each_ann['points'][1][1]))
bbox_w = bbox_right_bottom_x - bbox_left_top_x
bbox_h = bbox_right_bottom_y - bbox_left_top_y
bbox_dict['bbox'] = [bbox_left_top_x, bbox_left_top_y, bbox_w, bbox_h] # 左上角x、y、框的w、h
bbox_dict['area'] = bbox_w * bbox_h
# 筛选出分割多段线
for each_ann in labelme['shapes']: # 遍历所有标注
if each_ann['shape_type'] == 'polygon': # 筛选出分割多段线标注
# 第一个点的坐标
first_x = each_ann['points'][0][0]
first_y = each_ann['points'][0][1]
if (first_x>bbox_left_top_x) & (first_x<bbox_right_bottom_x) & (first_y<bbox_right_bottom_y) & (first_y>bbox_left_top_y): # 筛选出在该个体框中的关键点
bbox_dict['segmentation'] = list(map(lambda x: list(map(lambda y: round(y, 2), x)), each_ann['points'])) # 坐标保留两位小数
coco_annotations.append(bbox_dict)
return coco_annotations`
其中获取框坐标的过程中把浮点数转换成了整数,导致在后面
if (first_x>bbox_left_top_x) & (first_x<bbox_right_bottom_x) & (first_y<bbox_right_bottom_y) & (first_y>bbox_left_top_y): # 筛选出在该个体框中的关键点
的语句中可能会判断第一个点不一定在该框中从而跳过该实例分割的标注内容。
具体来说比如边界框右下角点的坐标是[10.1,10.1],因为取整取成了[10,10],而第一个标注点是[10.1,1],本该在框内却判断到了框外去
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.