Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you provide the innotation .json file for each dataset (unc, gref, gref_umd)? #3

Open
LeungWaiHo opened this issue Jun 2, 2022 · 4 comments

Comments

@LeungWaiHo
Copy link

LeungWaiHo commented Jun 2, 2022

Dear authors:
Thanks for your work in visual grounding, I also feel interested in this field, and I have a question:
Could you provide the innotation .json file for each dataset (unc, gref, gref_umd)?

@LeungWaiHo LeungWaiHo changed the title C欧蓝德 Could you provide the innotation .json file for each dataset (unc, gref, gref_umd)? Jun 2, 2022
@LukeForeverYoung
Copy link
Owner

The annotations of visual grounding tasks are included in the split files. These files are released by TransVG https://drive.google.com/file/d/1fVwdDvXNbH8uuq_pHD_o5HI7yqeuz0yS/view

@tiger990111
Copy link

I found that the Flickr30k dataset have 427,193 training pairs. But it suppose to be 29,783 training pairs. Is it some mistake of split file of Flickr30k?

@LeungWaiHo
Copy link
Author

The annotations of visual grounding tasks are included in the split files. These files are released by TransVG https://drive.google.com/file/d/1fVwdDvXNbH8uuq_pHD_o5HI7yqeuz0yS/view

Sorry, I mean the .json file for pre-training the weights of swin-Transformer.

@LukeForeverYoung
Copy link
Owner

The annotations of visual grounding tasks are included in the split files. These files are released by TransVG https://drive.google.com/file/d/1fVwdDvXNbH8uuq_pHD_o5HI7yqeuz0yS/view

Sorry, I mean the .json file for pre-training the weights of swin-Transformer.

You can generate the .json files by this script.

import torch
import json
from pathlib import Path
from icecream import ic
def get_img_set(p):
    datas=torch.load(p)
    imgs=[_[0] for _ in datas]
    return imgs

def convert_filename_4to7(name):
    return name[15:]

dataset_vt={
    'unc':['data/unc/unc_testA.pth','data/unc/unc_testB.pth','data/unc/unc_val.pth'],
    'unc+':['data/unc+/unc+_testA.pth','data/unc+/unc+_testB.pth','data/unc+/unc+_val.pth'],
    'gref':['data/gref/gref_val.pth'],
    'gref_umd':['data/gref_umd/gref_umd_test.pth','data/gref_umd/gref_umd_val.pth']

}
json_path='/mnt/ssd/Datasets/mscoco/images/annotations/instances_train2017.json'

if __name__=='__main__':
    for dataset,vt_list in dataset_vt.items():
        ic(dataset)
        img_set=[]
        for split_path in vt_list:
            img_set.extend(get_img_set(split_path))
        ic(img_set[:10])
        img_set=set(map(convert_filename_4to7,img_set))
        ic(list(img_set)[:10])
        with open(json_path,'r') as f:
            anno=json.load(f)
            for key in anno:
                ic(key)
            ic(len(anno['images']))
            ic(len(anno['annotations']))
            
            valid_img=set([img['id'] for img in anno['images'] if img['file_name'] not in img_set])

            anno['images']=[_ for _ in anno['images'] if _['id'] in valid_img]
            anno['annotations']=[_ for _ in anno['annotations'] if _['image_id'] in valid_img]

            ic(len(anno['images']))
            ic(len(anno['annotations']))
        with open(Path('coco_excluded',f'{dataset}.json'),'w')as f:
            json.dump(anno,f)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants