-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataset_mipt.py
89 lines (43 loc) · 1.13 KB
/
dataset_mipt.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- coding: utf-8 -*-
import cv2
from glob import glob
import os
from tqdm import tqdm
import json
import matplotlib.pyplot as plt
# In[]:
#folder = '/home/kenny/dgx/home/datasets/ir/mipt/'
folder = '/home/datasets/ir/mipt/'
# In[]:
with open(folder + 'test_info.json') as json_file:
train_data = json.load(json_file)
# annotations = train_data['annotations']
categories = train_data['categories']
images = train_data['images']
for img in images:
img['file_name'] = folder + 'images/' + img['name']
del(img['name'])
test_data = {'categories': categories,
'images': images
}
with open('test_data.json', 'w') as outfile:
json.dump(test_data, outfile)
# In[]:
#for ann in annotations:
#
# ann = annotations[2]
# img = cv2.imread(folder + 'images/' + images[ann['image_id']]['name'], 0)
# bbox = ann['bbox']
# cv2.rectangle(img, (int(bbox[0]), int(bbox[1])), (int(bbox[0]+bbox[2]), int(bbox[1]+bbox[3])), (255, 0, 0), 2)
# plt.imshow(img)
#
# break
# In[]:
# In[]:
# In[]:
# In[]:
# In[]:
# In[]:
# In[]:
# In[]:
# In[]: