-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.py
67 lines (44 loc) · 1.22 KB
/
results.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
63
# -*- coding: utf-8 -*-
import cv2
from glob import glob
import os
from tqdm import tqdm
import json
import matplotlib.pyplot as plt
import pickle
# In[]:
folder = 'results/combined/'
with open(folder + 'res_combined.pkl', 'rb') as f:
results = pickle.load(f)
# In[]:
res_list = []
thresh = 0.0001
for i, res in enumerate(results):
persons = res[0]
for person in persons:
x,y,x2,y2,s = person
w = x2-x
h = y2-y
if s > thresh:
res_list.append({"image_id" : i,
"category_id" : 1,
"bbox" : [float(x), float(y), float(w), float(h)],
"score" : float(0)
})
cars = res[1]
for car in cars:
x,y,x2,y2,s = car
w = x2-x
h = y2-y
if s > thresh:
res_list.append({"image_id" : i,
"category_id" : 2,
"bbox" : [float(x), float(y), float(w), float(h)],
"score" : float(0)
})
# In[]:
with open(folder + 'dt.json', 'w') as outfile:
json.dump(res_list, outfile)
# In[]:
# In[]:
# In[]: