-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevaluate.py
62 lines (51 loc) · 1.72 KB
/
evaluate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import argparse
def parse_arguments():
parser = argparse.ArgumentParser(
prog='Evaluation Metrics for OCR')
parser.add_argument(
'-d',
dest='detection_mode',
action='store_true',
help='Detection mode')
parser.add_argument(
'-r',
dest='recognition_mode',
action='store_true',
help='Recognition mode')
parser.add_argument(
'-gt',
'--gtfolder',
dest='gt_folder',
help='folder containing your ground truth JSON and images')
parser.add_argument(
'--gt-txt',
dest='gt_txt',
help='TSV file with your ground truth labels and image paths for recognition')
parser.add_argument(
'-det',
'--detfolder',
dest='det_folder',
default=None,
help='folder containing your detected bounding boxes JSON files')
parser.add_argument(
'-cfg',
'--config',
dest='config',
default=None,
help='config JSON file')
return parser.parse_args()
if __name__ == '__main__':
args = parse_arguments()
if args.detection_mode:
if not args.det_folder:
exit('Provide --detfolder for detected outputs')
if not args.gt_folder:
exit('Provide --gtfolder for ground truth')
from indic_ocr.evaluation.detection import eval_detections
eval_detections(args.gt_folder, args.det_folder)
if args.recognition_mode:
if not args.config:
exit('Provide --config file')
gt = args.gt_folder if args.gt_folder else args.gt_txt
from indic_ocr.evaluation.recognition import RecognizerEval
RecognizerEval(args.config).eval(gt)