forked from alexmorimitsu/IAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_impar_after_01_22.py
62 lines (46 loc) · 2.05 KB
/
run_impar_after_01_22.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 shutil
from random import shuffle
from math import ceil
from os import listdir, mkdir, system
from os.path import isfile, isdir, join, exists, getmtime
from knn_labeling import run_knn
from time import strftime, localtime
def map_ids(images_path):
map_id_to_batch = {}
l = listdir(join('main', images_path))
l.sort()
for i in range(len(l)):
map_id_to_batch[i+1] = l[i]
return map_id_to_batch
def print_batches(dataframes_path, map_id_to_batch, project_name):
for key in map_id_to_batch.keys():
csv_name = map_id_to_batch[key] + '_' + project_name + '.csv'
mod_time = getmtime(join(dataframes_path, csv_name))
mod_date = strftime('%Y-%m-%d %H:%M:%S', localtime(mod_time))
print('batch ' + str(key) + ': \t' + csv_name + ' \tLast modification: ' + mod_date)
def check_input(text, max_num):
try:
assert int(text) > 0
assert int(text) <= max_num
return True
except:
print('Batch size should be an integer between 1 and', max_num)
projects_path = 'main/assets/'
project_name = 'impar_after_01_22'
dataframes_path = 'main/assets/' + project_name + '/dataframes/'
samples_path = 'main/assets/' + project_name + '/samples/' + project_name
images_path = 'assets/' + project_name + '/images/'
thumbnails_path = 'assets/' + project_name + '/thumbnails/'
batches_path = join('main', images_path)
num_batches = len(listdir(batches_path))
map_id_to_batch = map_ids(images_path)
print_batches(dataframes_path, map_id_to_batch, project_name)
text = input('\nChoose batch for labeling: ')
while not check_input(text, num_batches):
text = input('\nChoose batch for labeling: ')
batch_id = int(text)
path_to_images = join(images_path, map_id_to_batch[batch_id], 'samples/')
path_to_thumbnails = join(thumbnails_path, map_id_to_batch[batch_id], 'samples/')
path_to_csv = dataframes_path + map_id_to_batch[batch_id] + '_' + project_name + '.csv'
print(path_to_csv)
system('python main/app.py ' + path_to_images + ' ' + path_to_thumbnails + ' ' + path_to_csv + ' 100')