Open fukancv opened 1 year ago
Same question here, when the code will be updated? @yuhangzang
The same question, ask for "instances_val2017_all_2.json"
you can follow https://github.com/alirezazareian/ovr-cnn/blob/master/ipynb/005.ipynb to generate the "instances_val2017_all_2.json". I past my revised code below: `import json import json import numpy as np import torch
with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017.json', 'r') as fin: coco_val_anno_all = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017.json', 'r') as fin: coco_val_anno_seen = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017.json', 'r') as fin: coco_val_anno_unseen = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/mscoco_seen_classes.json', 'r') as fin: labels_seen = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/mscoco_unseen_classes.json', 'r') as fin: labels_unseen = json.load(fin)
len(labels_seen), len(labels_unseen) labels_all = [item['name'] for item in coco_val_anno_all['categories']] set(labels_seen) - set(labels_all) set(labels_unseen) - set(labels_all) class_id_to_split = {} class_name_to_split = {} for item in coco_val_anno_all['categories']: if item['name'] in labels_seen: class_id_to_split[item['id']] = 'seen' class_name_to_split[item['name']] = 'seen' elif item['name'] in labels_unseen: class_id_to_split[item['id']] = 'unseen' class_name_to_split[item['name']] = 'unseen'
def filter_annotation(anno_dict, split_name_list): filtered_categories = [] filtered_images = [] filtered_annotations = [] useful_image_ids = set() for item in anno_dict['annotations']: if class_id_to_split.get(item['category_id']) in split_name_list: filtered_annotations.append(item) useful_image_ids.add(item['image_id']) for item in anno_dict['images']: if item['id'] in useful_image_ids: filtered_images.append(item) anno_dict['annotations'] = filtered_annotations anno_dict['images'] = filtered_images
filter_annotation(coco_val_anno_all, ['seen', 'unseen']) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017_all_2.json', 'w') as fout: json.dump(coco_val_anno_all, fout)`
you can follow https://github.com/alirezazareian/ovr-cnn/blob/master/ipynb/005.ipynb to generate the "instances_val2017_all_2.json". I past my revised code below: `import json import json import numpy as np import torch
with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017.json', 'r') as fin: coco_val_anno_all = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017.json', 'r') as fin: coco_val_anno_seen = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017.json', 'r') as fin: coco_val_anno_unseen = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/mscoco_seen_classes.json', 'r') as fin: labels_seen = json.load(fin) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/mscoco_unseen_classes.json', 'r') as fin: labels_unseen = json.load(fin)
len(labels_seen), len(labels_unseen) labels_all = [item['name'] for item in coco_val_anno_all['categories']] set(labels_seen) - set(labels_all) set(labels_unseen) - set(labels_all) class_id_to_split = {} class_name_to_split = {} for item in coco_val_anno_all['categories']: if item['name'] in labels_seen: class_id_to_split[item['id']] = 'seen' class_name_to_split[item['name']] = 'seen' elif item['name'] in labels_unseen: class_id_to_split[item['id']] = 'unseen' class_name_to_split[item['name']] = 'unseen'
def filter_annotation(anno_dict, split_name_list): filtered_categories = [] filtered_images = [] filtered_annotations = [] useful_image_ids = set() for item in anno_dict['annotations']: if class_id_to_split.get(item['category_id']) in split_name_list: filtered_annotations.append(item) useful_image_ids.add(item['image_id']) for item in anno_dict['images']: if item['id'] in useful_image_ids: filtered_images.append(item) anno_dict['annotations'] = filtered_annotations anno_dict['images'] = filtered_images
filter_annotation(coco_val_anno_all, ['seen', 'unseen']) with open('/root/bigModel/OV-DETR-main/ovdetr/coco/coco2017/annotations/instances_val2017_all_2.json', 'w') as fout: json.dump(coco_val_anno_all, fout)`
Thank you. It works well.
Hi, it has been 4 months since you last updated the code. However, the lvis related dataset files have not been updated. Moreover, I only find the train annotation jsons, but I don't find the val annotation jsons. Can you upload related files? Thanks.