Visual-Template-Free-Form-Parsing icon indicating copy to clipboard operation
Visual-Template-Free-Form-Parsing copied to clipboard

while run the eval.py of detector on the test data ,why need the json of test data ?

Open xuyuhui666 opened this issue 5 years ago • 3 comments

this is my order: -c min_saved/detector/checkpoint-latest.pth -g 0 -n 1 -d output -T but to run test data , why need the json data

xuyuhui666 avatar Nov 27 '19 13:11 xuyuhui666

They are giving metrics to show how good their model is. I wrote a small script to populate the jsons in the NAF_ data/NAF_dataset/groups directory.

import os
import json
import sys
data = {}
dir_names = sys.argv[1:]
current_dir = os.getcwd()
test = {}
for dir_name in dir_names:
	files = os.listdir(dir_name)
	imgs = [x for x in files if ('.jpg' in x) or ('.png' in x)]
	test[dir_name]=[]
	for img_name in imgs:
	    test[dir_name].append(img_name)
	    with open(os.path.join(current_dir,dir_name,img_name[:-4]+'.json'),'w') as f:
	        f.write('{"textBBs":[],"fieldBBs":[],"pairs":[]}')
data["test"]=test
data["train"]={}
data["val"]={}
print(data)
with open('../train_valid_test_split.json','w') as json_file:
    json.dump(data,json_file,indent=4)

Just run the above with the directory names as arguments while in the data/NAF_dataset/groups/ directory. But you are right, there can be an option of not supplying the jsons at all.

devarshi16 avatar Dec 02 '19 07:12 devarshi16

Thanks for your reply There is an option of specifying the image name,but it can't run While load test data ,the dataset is None.Since the function of test images without json is not developed

xuyuhui666 avatar Dec 06 '19 06:12 xuyuhui666

Yes, You can perhaps add that feature. For now though, if you wish to run the detector model on say multiple images in folders, you can use the code I provided above. It generates the json without bounding boxes and places it where required. It is only a workaround though, I agree.

devarshi16 avatar Dec 08 '19 12:12 devarshi16