未验证 提交 971dcbd8 编写于 作者: J Jason 提交者: GitHub

Merge pull request #232 from SunAhong1993/develop

modify the labelme2coco.py
......@@ -36,4 +36,6 @@ paddlex --data_conversion --source labelme --to PascalVOC --pics ./pics --annota
| --pics | 指定原图所在的目录路径 |
| --annotations | 指定标注文件所在的目录路径 |
**注意**:精灵标注的目标检测数据可以在工具内部导出为PascalVOC格式,因此paddlex未提供精灵标注数据到PascalVOC格式的转换
**注意**
1. 精灵标注的目标检测数据可以在工具内部导出为PascalVOC格式,因此paddlex未提供精灵标注数据到PascalVOC格式的转换
2. 在将LabelMe数据集转换为COCO数据集时,LabelMe的图像文件名和json文件名需要一一对应,才可正确转换
......@@ -96,12 +96,13 @@ class LabelMe2COCO(X2COCO):
def __init__(self):
super(LabelMe2COCO, self).__init__()
def generate_images_field(self, json_info, image_id):
def generate_images_field(self, json_info, image_file, image_id):
image = {}
image["height"] = json_info["imageHeight"]
image["width"] = json_info["imageWidth"]
image["id"] = image_id + 1
json_info["imagePath"] = path_normalization(json_info["imagePath"])
json_img_path = path_normalization(json_info["imagePath"])
json_info["imagePath"] = osp.join(osp.split(json_img_path)[0], image_file)
image["file_name"] = osp.split(json_info["imagePath"])[-1]
return image
......@@ -152,7 +153,7 @@ class LabelMe2COCO(X2COCO):
with open(json_file, mode='r', \
encoding=get_encoding(json_file)) as j:
json_info = json.load(j)
img_info = self.generate_images_field(json_info, image_id)
img_info = self.generate_images_field(json_info, img_file, image_id)
self.images_list.append(img_info)
for shapes in json_info["shapes"]:
object_id = object_id + 1
......@@ -360,6 +361,4 @@ class JingLing2COCO(X2COCO):
points.append([obj["bndbox"]["xmax"], obj["bndbox"]["ymin"]])
self.annotations_list.append(
self.generate_rectangle_anns_field(points, label, image_id,
object_id, label_to_num))
\ No newline at end of file
object_id, label_to_num))
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册