mirror of
https://github.com/wassname/sloth.git
synced 2026-07-29 11:27:41 +08:00
write more sensible error messages to console if items do not contain a 'class' key
This commit is contained in:
@@ -519,7 +519,11 @@ class AnnotationModelItem(KeyValueModelItem):
|
||||
def data(self, role=Qt.DisplayRole, column=0):
|
||||
if role == Qt.DisplayRole:
|
||||
if column == 0:
|
||||
return self['class']
|
||||
try:
|
||||
return self['class']
|
||||
except KeyError:
|
||||
LOG.error('Could not find key class in annotation item. Please check your label file.')
|
||||
return '<error - no class set>'
|
||||
elif column == 1 and self.isUnconfirmed():
|
||||
return '[unconfirmed]'
|
||||
else:
|
||||
|
||||
@@ -98,7 +98,11 @@ class AnnotationScene(QGraphicsScene):
|
||||
child = self._image_item.childAt(row)
|
||||
if not isinstance(child, AnnotationModelItem):
|
||||
continue
|
||||
label_class = child['class']
|
||||
try:
|
||||
label_class = child['class']
|
||||
except KeyError:
|
||||
LOG.error('Could not find key class in annotation item. Skipping this item. Please check your label file.')
|
||||
continue
|
||||
item = self._itemfactory.create(label_class, child)
|
||||
if item is not None:
|
||||
self.addItem(item)
|
||||
|
||||
Reference in New Issue
Block a user