ucas-vg / TOV_mmdetection

Include mmdetection version of TinyBenchmark. Official link.
https://github.com/ucas-vg/TinyBenchmark
Apache License 2.0
34 stars 2 forks source link

The picture exists in the dataset, but cannot be opened because of the picture name. Change the picture name to open the picture. I would like to ask, in case of this problem, just change the picture name? Or should corresponding changes be made in other files??? #7

Closed sxy1122 closed 2 years ago

sxy1122 commented 3 years ago

FileNotFoundError: [Errno 2] No such file or directory: tiny_set/test/labeled_images/google_P000_Porthleven-Surf-Sep2017-©EdBlomfield-100.jpg'

yinglang commented 3 years ago

if you have to change the file name, maybe you need fille name in mini_annotations/tiny_set_test_all.json. such as following code:

def find_by_name(jd, filename):
    ids = []
    for i, img in enumerate(jd['images']):
        if img['file_name'] == filename:
            ids.apend(i)
    return ids

import json
jd = json.load(open('mini_annotations/tiny_set_test_all.json'))
ids = find_by_name(jd, r'labeled_images/google_P000_Porthleven-Surf-Sep2017-©EdBlomfield-100.jpg')
for i in ids:
    jd['images'][i] = new_name
json.dump(new_name, open('mini_annotations/new_tiny_set_test_all.json', 'w'))

Using mini_annotations/new_tiny_set_test_all.json insted the origin json file should works, And maybe you need to do some modification on the given code.

sxy1122 commented 3 years ago

Excuse me, where should I add these codes?

yinglang commented 3 years ago

The codes is not a plugin or something need to be added. It is an independent script that can modify recorded file name of images in the coco format annotation file.

When training or evaluating your model, you need a annotation file which record all images' infomation(such as file name). And in TinyPerson, we use standard COCO annotation format. The program will try to load all image according to the file name recorded in annotation file. So when you change the file name of image, you need to modified the file name recorded in annotation file too.

The file tiny_set/test/labeled_images/google_P000_Porthleven-Surf-Sep2017-©EdBlomfield-100.jpg should record in mini_annotations/tiny_set_test_all.json.

The annotation file is json format which can read by human, you can open the annotation file with some editer directly and modified the file name. But the file size is too large, your editer may blocked. So we suggest to write a program to do modification. The code we given before is an independent program to do such modification.