xml中的注释转换为json?

问题描述 投票:1回答:1

我使用MASK RCNN keras和tensorflow,我想知道是否有人能够使用xml注释文件进行训练,或者是否有人将xml转换为json。如果我将我的xml文件更改为json,有人可以向我展示如何使用load_()函数的示例吗?

我用VIA工具做了一些注释并且它是正确的,(训练和检测)但我真的想使用xml注释因为已经完成并且需要很长时间才能重新开始。

我已将我的xml文件转换为json,但我的注释中没有多边形或区域,我该如何使用它?谢谢。

我会很感激。

annotations1 = json.load(open(os.path.join(dataset_dir, "dataset.json")))

        annotations = list(annotations1.values())  # don't need the dict keys

        annotations = [a for a in annotations if a['images']]

        for a in annotations:

            polygons = [r['shape_attributes'] for r in a['regions'].values()]

            image_path = os.path.join(dataset_dir, a['filename'])
            image = skimage.io.imread(image_path)
            height, width = image.shape[:2]

            self.add_image(
                "damage",  
                image_id=a['filename'],  
                path=image_path,
                width=width, height=height,
                polygons=polygons)
python tensorflow machine-learning keras computer-vision
1个回答
1
投票

您需要创建自己的脚本以从XML转换为JSON,或者只需删除load_mask()函数。

© www.soinside.com 2019 - 2024. All rights reserved.