Skip to content

coco_to_labelImg模块只存在bbox时,会出现丢失问题 #13

@SWHL

Description

@SWHL

问题描述

当前代码假定COCO数据集中必然存在segmentation字段,才会正常转换。

seg_info = one_anno.get("segmentation")
if seg_info:
bbox = self.get_bbox(seg_info)
xywh = self.xyxy_to_xywh(bbox, img_width, img_height)
category_id = int(one_anno.get("category_id")) - 1
xywh_str = " ".join([str(v) for v in xywh])
label_str = f"{category_id} {xywh_str}"
# 写入标注的txt文件
txt_full_path = save_dir / f"{Path(img_name).stem}.txt"
self.write_txt(txt_full_path, label_str, mode="a")

如果仅仅存在bbox字段,但是没有segmentation字段,则程序会为空!

所用版本

label_convert==0.1.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions