Ver Fonte

add feature: instance label auto increment

Lingjie Zhu há 6 anos atrás
pai
commit
0ec892ad01
2 ficheiros alterados com 9 adições e 0 exclusões
  1. 8 0
      labelme/app.py
  2. 1 0
      labelme/config/default_config.yaml

+ 8 - 0
labelme/app.py

@@ -1034,7 +1034,15 @@ class MainWindow(QtWidgets.QMainWindow):
         if items:
             text = items[0].text()
         if self._config['display_label_popup'] or not text:
+            # instance label auto increment
+            if self._config['instance_label_auto_increment']:
+                previous_label = self.labelDialog.edit.text()
+                split = previous_label.split('-')
+                if len(split) > 1 and split[-1].isdigit():
+                    split[-1] = str(int(split[-1]) + 1)
+                    text = '-'.join(split)
             text = self.labelDialog.popUp(text)
+
         if text is not None and not self.validateLabel(text):
             self.errorMessage('Invalid label',
                               "Invalid label '{}' with validation type '{}'"

+ 1 - 0
labelme/config/default_config.yaml

@@ -1,5 +1,6 @@
 auto_save: false
 display_label_popup: true
+instance_label_auto_increment: true
 store_data: true
 keep_prev: false
 logger_level: info