forked from floft/detect-frying-pan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sloth_config.py
105 lines (101 loc) · 5.03 KB
/
sloth_config.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
103
104
105
# This is sloth's default configuration.
#
# The configuration file is a simple python module with module-level
# variables. This module contains the default values for sloth's
# configuration variables.
#
# In all cases in the configuration where a python callable (such as a
# function, class constructor, etc.) is expected, it is equally possible
# to specify a module path (as string) pointing to such a python callable.
# It will then be automatically imported.
# LABELS
#
# List/tuple of dictionaries that defines the label classes
# that are handled by sloth. For each label, there should
# be one dictionary that contains the following keys:
#
# - 'item' : Visualization item for this label. This can be
# any python callable or a module path string
# implementing the visualization item interface.
#
# - 'inserter' : (optional) Item inserter for this label.
# If the user selects to insert a new label of this class
# the inserter is responsible to actually
# capture the users mouse actions and insert
# a new label into the annotation model.
#
# - 'hotkey' : (optional) A keyboard shortcut starting
# the insertion of a new label of this class.
#
# - 'attributes' : (optional) A dictionary that defines the
# keys and possible values of this label
# class.
#
# - 'text' : (optional) A label for the item's GUI button.
LABELS = (
{
'attributes': {
'class': 'laptop',
},
'inserter': 'sloth.items.RectItemInserter',
'item': 'sloth.items.RectItem',
'hotkey': 'f',
'text': 'Laptop',
},
)
# HOTKEYS
#
# Defines the keyboard shortcuts. Each hotkey is defined by a tuple
# with at least 2 entries, where the first entry is the hotkey (sequence),
# and the second entry is the function that is called. The function
# should expect a single parameter, the labeltool object. The optional
# third entry -- if present -- is expected to be a string describing the
# action.
HOTKEYS = (
('Space', [lambda lt: lt.currentImage().confirmAll(),
lambda lt: lt.currentImage().setUnlabeled(False),
lambda lt: lt.gotoNext()
], 'Mark image as labeled/confirmed and go to next'),
('Backspace', lambda lt: lt.gotoPrevious(), 'Previous image/frame'),
('PgDown', lambda lt: lt.gotoNext(), 'Next image/frame'),
('PgUp', lambda lt: lt.gotoPrevious(), 'Previous image/frame'),
('Tab', lambda lt: lt.selectNextAnnotation(), 'Select next annotation'),
('Shift+Tab', lambda lt: lt.selectPreviousAnnotation(), 'Select previous annotation'),
('Ctrl+f', lambda lt: lt.view().fitInView(), 'Fit current image/frame into window'),
('Del', lambda lt: lt.deleteSelectedAnnotations(), 'Delete selected annotations'),
('Ctrl+Shift+Del', [lambda lt: lt.selectAllAnnotations(),
lambda lt: lt.deleteSelectedAnnotations(),
lambda lt: lt.setUnlabeled(True)],'Delete all annotations on this image and mark it as unlabeled'),
('ESC', lambda lt: lt.exitInsertMode(), 'Exit insert mode'),
('Shift+l', lambda lt: lt.currentImage().setUnlabeled(False), 'Mark current image as labeled'),
('Shift+c', lambda lt: lt.currentImage().confirmAll(), 'Mark all annotations in image as confirmed'),
('c', lambda lt: lt.mainWindow().copyAnnotations.copy(), 'Copy all annotations from the previous image to this one'),
('n', [lambda lt: lt.currentImage().confirmAll(),
lambda lt: lt.currentImage().setUnlabeled(False),
lambda lt: lt.gotoNext(),
lambda lt: lt.mainWindow().copyAnnotations.copy()
], 'Mark image as labeled/confirmed and go to next then copy all annotations from the previous image.'),
#('F5', lambda lt: toggleShowLabels(), 'Toggle showing labels on boxes'),
)
# CONTAINERS
#
# A list/tuple of two-tuples defining the mapping between filename pattern and
# annotation container classes. The filename pattern can contain wildcards
# such as * and ?. The corresponding container is expected to either a python
# class implementing the sloth container interface, or a module path pointing
# to such a class.
CONTAINERS = (
('*.json', 'sloth.annotations.container.JsonContainer'),
('*.msgpack', 'sloth.annotations.container.MsgpackContainer'),
('*.yaml', 'sloth.annotations.container.YamlContainer'),
('*.pickle', 'sloth.annotations.container.PickleContainer'),
('*.sloth-init', 'sloth.annotations.container.FileNameListContainer'),
)
# PLUGINS
#
# A list/tuple of classes implementing the sloth plugin interface. The
# classes can either be given directly or their module path be specified
# as string.
PLUGINS = (
#('plugins.label_remover.LabelRemoverPlugin',)
)