-
Notifications
You must be signed in to change notification settings - Fork 0
/
subset_generator.py
executable file
·102 lines (75 loc) · 2.7 KB
/
subset_generator.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 6 11:59:03 2019
@author: nelson
"""
import glob
import json
countable_classes = ['animal', 'bike', 'bus', 'car', 'cone', 'moto', 'person', 'truck']
def generate_list(path, search_fragment):
my_list = glob.glob(path+'**.json')
count=0
with open(path+'small.txt', 'w') as f:
for item in my_list:
if search_fragment in item:
f.write("%s\n" % item[item.rfind('/')+1:-5])
count +=1
elif any([name in shape['label'] for shape in json.load(open(item))['shapes'] for name in countable_classes]):
f.write("%s\n" % item[item.rfind('/')+1:-5])
count +=1
return count
# root_path = '/home/nelson/projects/da_art_perception/data/dataset'
root_path = './'
count = 0
path = root_path + '/off-road/night/cimatec-industrial/'
search_fragment = '005cc'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/off-road/day/cimatec-industrial/'
search_fragment = '001_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/off-road/evening/cimatec-industrial/'
search_fragment = '001cc'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/off-road/rain/cimatec-industrial/'
search_fragment = 'cim_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/unpaved/day/estrada-dos-tropeiros/'
search_fragment = '001_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/unpaved/day/jaua/'
search_fragment = 'jt_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/unpaved/day/praia-do-forte/'
search_fragment = 'k1_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/unpaved/rain/estrada-dos-tropeiros/'
search_fragment = 'c0_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/unpaved/rain/jaua/'
search_fragment = 'c0_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
path = root_path + '/unpaved/rain/praia-do-forte/'
search_fragment = 'd1_'
count_ = generate_list(path, search_fragment)
print(path+' has ' + str(count_) + ' images')
count += count_
print('The subset has ' + str(count) + ' images')