我在使用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()) # 不需要字典键 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()
函数。