-
Notifications
You must be signed in to change notification settings - Fork 3
/
label.py
41 lines (35 loc) · 1.12 KB
/
label.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
import json
import os
import sys
from labeller import (
LabelHelper, PartiallyLabelledDataset,
ask_directory, MessageBox
)
if __name__ == '__main__':
argc = len(sys.argv)
dirname = None
if argc == 1:
dirname = ask_directory('Select a dataset root directory')
elif argc == 2:
dirname = sys.argv[1]
else:
print('Usage: "{}" or "{} [/path/to/dataset]"'.format(sys.argv[0], sys.argv[0]))
exit(1)
try:
if dirname is not None:
# Load parially labelled dataset
dataset = PartiallyLabelledDataset()
dataset.load(dirname)
# Load info.json if it is found under the dataset root directory
info_path = os.path.join(dirname, 'info.json')
if os.path.isfile(info_path):
with open(info_path, 'r') as fp:
info = json.load(fp)
else:
info = None
# Create label helper
helper = LabelHelper(dataset, info)
helper.mainloop()
except Exception as e:
win = MessageBox(str(e), 'Failure')
win.mainloop()