forked from zylo117/Yet-Another-EfficientDet-Pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproperty.py
49 lines (34 loc) · 1.06 KB
/
property.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
import os
import json
from itertools import combinations
import util
def process(video_path):
cls = util.cls
count = util.count
skip_res = {'class': [], 'score': []}
length = 0
with open(os.path.join(video_path, 'res-7.json')) as f:
exec_res = json.load(f)
length = len(exec_res)
with open(os.path.join(video_path, 'gt.json')) as f:
gt = json.load(f)
tp = 0
for k in range(length):
if str(k) in gt and util.evaluate(cls, count, gt[str(k)], use_gt=True):
tp += 1
print(tp / length)
def main():
tmp_working = []
base_dir = '/data/jiashenc/ua_detrac/test/'
for video_path in os.listdir(base_dir):
if len(tmp_working) != 0 and video_path not in tmp_working:
continue
skip = False
for l in range(8):
if not os.path.isfile(os.path.join(base_dir, video_path, 'res-{}.json'.format(l))):
skip = True
if skip:
continue
process(os.path.join(base_dir, video_path))
if __name__ == '__main__':
main()