Commit 6ae34749 authored by suilin0432's avatar suilin0432
Browse files

update

parent 7caeccf1
......@@ -32,13 +32,13 @@ from .pascal_voc import register_pascal_voc, register_pascal_voc_wsl, register_p
# ==== Predefined datasets and splits for COCO ==========
_PREDEFINED_SPLITS_COCO = {}
_PREDEFINED_SPLITS_COCO["voc"] = {
"voc_2012_seg_train": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance.json"),
"voc_2012_seg_val": ("VOC2012/JPEGImages", "VOC2012/voc_2012_val_instance.json"),
"voc_2012_seg_train_irn": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance_irn.json"),
"sbd_seg": ("VOC_SBD/images", "VOC2012/sbd_9118_instance.json"),
"voc_2012_seg_train_irn_plus_sbd": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance_irn_plus_sbd.json"),
}
# _PREDEFINED_SPLITS_COCO["voc"] = {
# "voc_2012_seg_train": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance.json"),
# "voc_2012_seg_val": ("VOC2012/JPEGImages", "VOC2012/voc_2012_val_instance.json"),
# "voc_2012_seg_train_irn": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance_irn.json"),
# "sbd_seg": ("VOC_SBD/images", "VOC2012/sbd_9118_instance.json"),
# "voc_2012_seg_train_irn_plus_sbd": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance_irn_plus_sbd.json"),
# }
_PREDEFINED_SPLITS_COCO["coco"] = {
"coco_2014_train": ("coco/train2014", "coco/annotations/instances_train2014.json"),
"coco_2014_val": ("coco/val2014", "coco/annotations/instances_val2014.json"),
......@@ -144,6 +144,14 @@ COCO_WSL = {
"coco_2014_valminusminival_casd_wsl_topone": ("coco/val2014", "coco/annotations/casd_valminusminival2014_wsl_topone.json"),
}
VOC_WSIS = {
"voc_2012_seg_train": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance.json"),
"voc_2012_seg_val": ("VOC2012/JPEGImages", "VOC2012/voc_2012_val_instance.json"),
"voc_2012_seg_train_irn": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance_irn.json"),
"sbd_seg": ("VOC_SBD/images", "VOC2012/sbd_9118_instance.json"),
"voc_2012_seg_train_irn_plus_sbd": ("VOC2012/JPEGImages", "VOC2012/voc_2012_train_instance_irn_plus_sbd.json"),
}
# 注册弱监督的打好 pgt 标记的数据集
def register_all_coco_wsl(root):
for key, (image_root, json_file) in COCO_WSL.items():
......@@ -154,6 +162,15 @@ def register_all_coco_wsl(root):
os.path.join(root, image_root)
)
def register_all_voc_wsis(root):
for key, (image_root, json_file) in VOC_WSIS.items():
register_coco_instances_wsl(
key,
_get_builtin_metadata("voc"),
os.path.join(root, json_file) if "://" not in json_file else json_file,
os.path.join(root, image_root)
)
def register_all_coco(root):
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_COCO.items():
for key, (image_root, json_file) in splits_per_dataset.items():
......@@ -532,6 +549,7 @@ if __name__.endswith(".builtin"):
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
register_all_coco(_root)
register_all_coco_wsl(_root)
register_all_voc_wsis(_root)
register_all_lvis(_root)
register_all_cityscapes(_root)
register_all_cityscapes_panoptic(_root)
......
......@@ -69,7 +69,6 @@ def load_coco_json(json_file, image_root, dataset_name=None, extra_annotation_ke
coco_api = COCO(json_file)
if timer.seconds() > 1:
logger.info("Loading {} takes {:.2f} seconds.".format(json_file, timer.seconds()))
id_map = None
if dataset_name is not None:
meta = MetadataCatalog.get(dataset_name)
......
......@@ -158,8 +158,8 @@ class COCOEvaluator(DatasetEvaluator):
else:
predictions = self._predictions
#import json
#json.dump(predictions, open("/mnt/data3/suilin/wsod/visual/fpn_{}.json".format(self._metadata.name), "w"))
# import json
# json.dump(predictions, open("/mnt/data3/suilin/wsod/visual/fpn_{}.json".format(self._metadata.name), "w"))
if len(predictions) == 0:
self._logger.warning("[COCOEvaluator] Did not receive valid predictions.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment