-
Notifications
You must be signed in to change notification settings - Fork 3
/
tag.py
43 lines (38 loc) · 1.2 KB
/
tag.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
import sys
import traceback
from datetime import datetime
import matplotlib.pyplot as plt
from labeller import (
TagHelper, ask_file, MessageBox
)
plt.rcParams['font.family'] = 'BM HANNA 11yrs old'
plt.rcParams['font.size'] = 15
if __name__ == '__main__':
argc = len(sys.argv)
filename = None
if argc == 1:
filename = ask_file(
'Select a *.json file.',
filetypes={'JSON file': '.json'}
)
elif argc == 2:
filename = sys.argv[1]
else:
print('Usage: "{}" or "{} [/path/to/dataset]"'.format(sys.argv[0], sys.argv[0]))
exit(1)
try:
if filename is not None:
# Create tag helper
helper = TagHelper(filename)
helper.mainloop()
except TagHelper.Exception as e:
win = MessageBox(str(e), 'Error')
win.mainloop()
except Exception:
with open('{}.error.log'.format(sys.argv[0]), 'a') as fp:
fp.write('{}\n'.format(datetime.now()))
fp.write('-' * 40 + '\n')
traceback.print_exc(file=fp)
fp.write('-' * 40 + '\n')
win = MessageBox('알 수 없는 오류가 발생하였습니다.', 'Error')
win.mainloop()