簡體   English   中英

xml中的注釋轉換為json?

[英]Annotations in xml convert to json?

我使用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)

您需要創建自己的腳本以將 XML 轉換為 JSON,或者干脆刪除load_mask()函數。

我真的需要涵蓋VCO到COCO格式(xml2json)。 你能幫我么? 我使用了腳本,但它不是正確的json格式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM