【问题标题】:Change Metadata values in python, Detectron2在 python,Detectron2 中更改元数据值
【发布时间】:2022-07-12 18:26:26
【问题描述】:

我使用 Detectron 进行全景分割。

我想将元数据值更改为我选择的值。 特别是,我想用我写的另一本字典替换一本字典。

但我得到了一个错误:

AssertionError: Attribute 'stuff_dataset_id_to_contiguous_id' in the metadata of 'coco_2017_train_panoptic_separated' cannot be set to a different value!

以下是我要更改的元数据:

MetadataCatalog.get(cfg.DATASETS.TRAIN[0]) -->

--> out:

Metadata(evaluator_type='coco_panoptic_seg', image_root='datasets/coco/train2017',
json_file='datasets/coco/annotations/instances_train2017.json', 
name='coco_2017_train_panoptic_separated', 
panoptic_json='datasets/coco/annotations/panoptic_train2017.json' 
[...]
stuff_dataset_id_to_contiguous_id={92: 1, 93: 2, 95: 3, 100: 4, 107: 5, 109: 6,
112: 7, 118: 8, 119: 9, 122: 10, 125: 11, 128: 12, 130: 13, 133: 14, 138: 15,
141: 16, [... etc etc]

我想将 stuff_dataset_id_to_contiguous_id 更改为另一个字典。

我能做什么?非常感谢。

【问题讨论】:

    标签: python dictionary pytorch computer-vision detectron


    【解决方案1】:

    您可以尝试像这样删除您之前注册的元数据:

    MetadataCatalog.remove("coco_2017_train_panoptic_separated")
    

    然后您可以打印所有已注册的元数据以检查您是否删除了您想要的内容:

    detectron2.data.MetadataCatalog
    

    然后像往常一样使用register_coco_instances()注册新的更改元数据。

    顺便说一句,您也可以对 DatasetCatalog 使用相同的语法:

    DatasetCatalog.remove("coco_2017_train_panoptic_separated")
    detectron2.data.DatasetCatalog
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 2022-09-06
      • 2017-12-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 2019-03-08
      相关资源
      最近更新 更多