【问题标题】:Annotations in xml convert to json?xml中的注释转换为json?
【发布时间】:2019-08-03 22:55:30
【问题描述】:

我正在使用 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】:

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

    【讨论】:

    • 谢谢,我做到了,我已经创建了自己的脚本来从 xml 转换为 json,而且我还必须在矩形区域之间创建点,因为您需要多边形形状。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-22
    • 2018-10-09
    • 1970-01-01
    • 2023-03-08
    • 2019-07-15
    • 2022-01-11
    • 1970-01-01
    相关资源
    最近更新 更多