未验证 提交 e7ef5ee4 编写于 作者: D Daniel Yang 提交者: GitHub

Merge pull request #1975 from Evezerest/dy1

Add new batch processing and undo functions
...@@ -206,7 +206,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -206,7 +206,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.labelList = EditInList() self.labelList = EditInList()
labelListContainer = QWidget() labelListContainer = QWidget()
labelListContainer.setLayout(listLayout) labelListContainer.setLayout(listLayout)
self.labelList.itemActivated.connect(self.labelSelectionChanged) #self.labelList.itemActivated.connect(self.labelSelectionChanged)
self.labelList.itemSelectionChanged.connect(self.labelSelectionChanged) self.labelList.itemSelectionChanged.connect(self.labelSelectionChanged)
self.labelList.clicked.connect(self.labelList.item_clicked) self.labelList.clicked.connect(self.labelList.item_clicked)
# Connect to itemChanged to detect checkbox changes. # Connect to itemChanged to detect checkbox changes.
...@@ -219,7 +219,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -219,7 +219,7 @@ class MainWindow(QMainWindow, WindowMixin):
################## detection box #################### ################## detection box ####################
self.BoxList = QListWidget() self.BoxList = QListWidget()
self.BoxList.itemActivated.connect(self.boxSelectionChanged) #self.BoxList.itemActivated.connect(self.boxSelectionChanged)
self.BoxList.itemSelectionChanged.connect(self.boxSelectionChanged) self.BoxList.itemSelectionChanged.connect(self.boxSelectionChanged)
self.BoxList.itemDoubleClicked.connect(self.editBox) self.BoxList.itemDoubleClicked.connect(self.editBox)
# Connect to itemChanged to detect checkbox changes. # Connect to itemChanged to detect checkbox changes.
...@@ -435,7 +435,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -435,7 +435,7 @@ class MainWindow(QMainWindow, WindowMixin):
######## New actions ####### ######## New actions #######
AutoRec = action(getStr('autoRecognition'), self.autoRecognition, AutoRec = action(getStr('autoRecognition'), self.autoRecognition,
'Ctrl+Shift+A', 'Auto', getStr('autoRecognition'), enabled=False) '', 'Auto', getStr('autoRecognition'), enabled=False)
reRec = action(getStr('reRecognition'), self.reRecognition, reRec = action(getStr('reRecognition'), self.reRecognition,
'Ctrl+Shift+R', 'reRec', getStr('reRecognition'), enabled=False) 'Ctrl+Shift+R', 'reRec', getStr('reRecognition'), enabled=False)
...@@ -444,7 +444,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -444,7 +444,7 @@ class MainWindow(QMainWindow, WindowMixin):
'Ctrl+R', 'reRec', getStr('singleRe'), enabled=False) 'Ctrl+R', 'reRec', getStr('singleRe'), enabled=False)
createpoly = action(getStr('creatPolygon'), self.createPolygon, createpoly = action(getStr('creatPolygon'), self.createPolygon,
'q', 'new', 'Creat Polygon', enabled=True) 'q', 'new', getStr('creatPolygon'), enabled=True)
saveRec = action(getStr('saveRec'), self.saveRecResult, saveRec = action(getStr('saveRec'), self.saveRecResult,
'', 'save', getStr('saveRec'), enabled=False) '', 'save', getStr('saveRec'), enabled=False)
...@@ -452,6 +452,12 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -452,6 +452,12 @@ class MainWindow(QMainWindow, WindowMixin):
saveLabel = action(getStr('saveLabel'), self.saveLabelFile, # saveLabel = action(getStr('saveLabel'), self.saveLabelFile, #
'Ctrl+S', 'save', getStr('saveLabel'), enabled=False) 'Ctrl+S', 'save', getStr('saveLabel'), enabled=False)
undoLastPoint = action(getStr("undoLastPoint"), self.canvas.undoLastPoint,
'Ctrl+Z', "undo", getStr("undoLastPoint"), enabled=False)
undo = action(getStr("undo"), self.undoShapeEdit,
'Ctrl+Z', "undo", getStr("undo"), enabled=False)
self.editButton.setDefaultAction(edit) self.editButton.setDefaultAction(edit)
self.newButton.setDefaultAction(create) self.newButton.setDefaultAction(create)
self.DelButton.setDefaultAction(deleteImg) self.DelButton.setDefaultAction(deleteImg)
...@@ -512,10 +518,11 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -512,10 +518,11 @@ class MainWindow(QMainWindow, WindowMixin):
zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg, zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg,
fitWindow=fitWindow, fitWidth=fitWidth, fitWindow=fitWindow, fitWidth=fitWidth,
zoomActions=zoomActions, saveLabel=saveLabel, zoomActions=zoomActions, saveLabel=saveLabel,
undo=undo, undoLastPoint=undoLastPoint,
fileMenuActions=( fileMenuActions=(
opendir, saveLabel, resetAll, quit), opendir, saveLabel, resetAll, quit),
beginner=(), advanced=(), beginner=(), advanced=(),
editMenu=(createpoly, edit, copy, delete,singleRere, editMenu=(createpoly, edit, copy, delete,singleRere,None, undo, undoLastPoint,
None, color1, self.drawSquaresOption), None, color1, self.drawSquaresOption),
beginnerContext=(create, edit, copy, delete, singleRere), beginnerContext=(create, edit, copy, delete, singleRere),
advancedContext=(createMode, editMode, edit, copy, advancedContext=(createMode, editMode, edit, copy,
...@@ -549,8 +556,13 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -549,8 +556,13 @@ class MainWindow(QMainWindow, WindowMixin):
self.labelDialogOption.setChecked(settings.get(SETTING_PAINT_LABEL, False)) self.labelDialogOption.setChecked(settings.get(SETTING_PAINT_LABEL, False))
self.labelDialogOption.triggered.connect(self.speedChoose) self.labelDialogOption.triggered.connect(self.speedChoose)
self.autoSaveOption = QAction(getStr('autoSaveMode'), self)
self.autoSaveOption.setCheckable(True)
self.autoSaveOption.setChecked(settings.get(SETTING_PAINT_LABEL, False))
self.autoSaveOption.triggered.connect(self.autoSaveFunc)
addActions(self.menus.file, addActions(self.menus.file,
(opendir, None, saveLabel, saveRec, None, resetAll, deleteImg, quit)) (opendir, None, saveLabel, saveRec, self.autoSaveOption, None, resetAll, deleteImg, quit))
addActions(self.menus.help, (showSteps, showInfo)) addActions(self.menus.help, (showSteps, showInfo))
addActions(self.menus.view, ( addActions(self.menus.view, (
...@@ -566,9 +578,9 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -566,9 +578,9 @@ class MainWindow(QMainWindow, WindowMixin):
# Custom context menu for the canvas widget: # Custom context menu for the canvas widget:
addActions(self.canvas.menus[0], self.actions.beginnerContext) addActions(self.canvas.menus[0], self.actions.beginnerContext)
addActions(self.canvas.menus[1], ( #addActions(self.canvas.menus[1], (
action('&Copy here', self.copyShape), # action('&Copy here', self.copyShape),
action('&Move here', self.moveShape))) # action('&Move here', self.moveShape)))
self.statusBar().showMessage('%s started.' % __appname__) self.statusBar().showMessage('%s started.' % __appname__)
...@@ -758,6 +770,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -758,6 +770,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.canvas.setEditing(False) self.canvas.setEditing(False)
self.canvas.fourpoint = True self.canvas.fourpoint = True
self.actions.create.setEnabled(False) self.actions.create.setEnabled(False)
self.actions.undoLastPoint.setEnabled(True)
def toggleDrawingSensitive(self, drawing=True): def toggleDrawingSensitive(self, drawing=True):
"""In the middle of drawing, toggling between modes should be disabled.""" """In the middle of drawing, toggling between modes should be disabled."""
...@@ -866,10 +879,11 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -866,10 +879,11 @@ class MainWindow(QMainWindow, WindowMixin):
self.updateComboBox() self.updateComboBox()
def updateBoxlist(self): def updateBoxlist(self):
shape = self.canvas.selectedShape for shape in self.canvas.selectedShapes+[self.canvas.hShape]:
item = self.shapesToItemsbox[shape] # listitem item = self.shapesToItemsbox[shape] # listitem
text = [(int(p.x()), int(p.y())) for p in shape.points] text = [(int(p.x()), int(p.y())) for p in shape.points]
item.setText(str(text)) item.setText(str(text))
self.actions.undo.setEnabled(True)
self.setDirty() self.setDirty()
def indexTo5Files(self, currIndex): def indexTo5Files(self, currIndex):
...@@ -902,23 +916,27 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -902,23 +916,27 @@ class MainWindow(QMainWindow, WindowMixin):
if len(self.mImgList) > 0: if len(self.mImgList) > 0:
self.zoomWidget.setValue(self.zoomWidgetValue + self.imgsplider.value()) self.zoomWidget.setValue(self.zoomWidgetValue + self.imgsplider.value())
# React to canvas signals.
def shapeSelectionChanged(self, selected=False): def shapeSelectionChanged(self, selected_shapes):
if self._noSelectionSlot: self._noSelectionSlot = True
self._noSelectionSlot = False for shape in self.canvas.selectedShapes:
else: shape.selected = False
shape = self.canvas.selectedShape self.labelList.clearSelection()
if shape: self.canvas.selectedShapes = selected_shapes
self.shapesToItems[shape].setSelected(True) for shape in self.canvas.selectedShapes:
self.shapesToItemsbox[shape].setSelected(True) # ADD shape.selected = True
else: self.shapesToItems[shape].setSelected(True)
self.labelList.clearSelection() self.shapesToItemsbox[shape].setSelected(True)
self.actions.delete.setEnabled(selected)
self.actions.copy.setEnabled(selected) self.labelList.scrollToItem(self.currentItem()) # QAbstractItemView.EnsureVisible
self.actions.edit.setEnabled(selected) self.BoxList.scrollToItem(self.currentBox())
self.actions.shapeLineColor.setEnabled(selected)
self.actions.shapeFillColor.setEnabled(selected) self._noSelectionSlot = False
self.actions.singleRere.setEnabled(selected) n_selected = len(selected_shapes)
self.actions.singleRere.setEnabled(n_selected)
self.actions.delete.setEnabled(n_selected)
self.actions.copy.setEnabled(n_selected)
self.actions.edit.setEnabled(n_selected == 1)
def addLabel(self, shape): def addLabel(self, shape):
shape.paintLabel = self.displayLabelOption.isChecked() shape.paintLabel = self.displayLabelOption.isChecked()
...@@ -941,22 +959,23 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -941,22 +959,23 @@ class MainWindow(QMainWindow, WindowMixin):
action.setEnabled(True) action.setEnabled(True)
self.updateComboBox() self.updateComboBox()
def remLabel(self, shape): def remLabels(self, shapes):
if shape is None: if shapes is None:
# print('rm empty label') # print('rm empty label')
return return
item = self.shapesToItems[shape] for shape in shapes:
self.labelList.takeItem(self.labelList.row(item)) item = self.shapesToItems[shape]
del self.shapesToItems[shape] self.labelList.takeItem(self.labelList.row(item))
del self.itemsToShapes[item] del self.shapesToItems[shape]
self.updateComboBox() del self.itemsToShapes[item]
self.updateComboBox()
# ADD: # ADD:
item = self.shapesToItemsbox[shape] item = self.shapesToItemsbox[shape]
self.BoxList.takeItem(self.BoxList.row(item)) self.BoxList.takeItem(self.BoxList.row(item))
del self.shapesToItemsbox[shape] del self.shapesToItemsbox[shape]
del self.itemsToShapesbox[item] del self.itemsToShapesbox[item]
self.updateComboBox() self.updateComboBox()
def loadLabels(self, shapes): def loadLabels(self, shapes):
s = [] s = []
...@@ -1001,7 +1020,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1001,7 +1020,7 @@ class MainWindow(QMainWindow, WindowMixin):
item.setText(str([(int(p.x()), int(p.y())) for p in shape.points])) item.setText(str([(int(p.x()), int(p.y())) for p in shape.points]))
self.updateComboBox() self.updateComboBox()
def updateComboBox(self): def updateComboBox(self): # TODO:貌似没用
# Get the unique labels and add them to the Combobox. # Get the unique labels and add them to the Combobox.
itemsTextList = [str(self.labelList.item(i).text()) for i in range(self.labelList.count())] itemsTextList = [str(self.labelList.item(i).text()) for i in range(self.labelList.count())]
...@@ -1054,26 +1073,38 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1054,26 +1073,38 @@ class MainWindow(QMainWindow, WindowMixin):
return False return False
def copySelectedShape(self): def copySelectedShape(self):
self.addLabel(self.canvas.copySelectedShape()) for shape in self.canvas.copySelectedShape():
self.addLabel(shape)
# fix copy and delete # fix copy and delete
self.shapeSelectionChanged(True) #self.shapeSelectionChanged(True)
def labelSelectionChanged(self): def labelSelectionChanged(self):
item = self.currentItem() if self._noSelectionSlot:
self.labelList.scrollToItem(item, QAbstractItemView.EnsureVisible) return
if item and self.canvas.editing(): if self.canvas.editing():
self._noSelectionSlot = True selected_shapes = []
self.canvas.selectShape(self.itemsToShapes[item]) for item in self.labelList.selectedItems():
shape = self.itemsToShapes[item] selected_shapes.append(self.itemsToShapes[item])
if selected_shapes:
self.canvas.selectShapes(selected_shapes)
else:
self.canvas.deSelectShape()
def boxSelectionChanged(self): def boxSelectionChanged(self):
item = self.currentBox() if self._noSelectionSlot:
self.BoxList.scrollToItem(item, QAbstractItemView.EnsureVisible) #self.BoxList.scrollToItem(self.currentBox(), QAbstractItemView.PositionAtCenter)
if item and self.canvas.editing(): return
self._noSelectionSlot = True if self.canvas.editing():
self.canvas.selectShape(self.itemsToShapesbox[item]) selected_shapes = []
shape = self.itemsToShapesbox[item] for item in self.BoxList.selectedItems():
selected_shapes.append(self.itemsToShapesbox[item])
if selected_shapes:
self.canvas.selectShapes(selected_shapes)
else:
self.canvas.deSelectShape()
def labelItemChanged(self, item): def labelItemChanged(self, item):
shape = self.itemsToShapes[item] shape = self.itemsToShapes[item]
...@@ -1113,6 +1144,8 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1113,6 +1144,8 @@ class MainWindow(QMainWindow, WindowMixin):
if self.beginner(): # Switch to edit mode. if self.beginner(): # Switch to edit mode.
self.canvas.setEditing(True) self.canvas.setEditing(True)
self.actions.create.setEnabled(True) self.actions.create.setEnabled(True)
self.actions.undoLastPoint.setEnabled(False)
self.actions.undo.setEnabled(True)
else: else:
self.actions.editMode.setEnabled(True) self.actions.editMode.setEnabled(True)
self.setDirty() self.setDirty()
...@@ -1548,6 +1581,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1548,6 +1581,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.fileListWidget.insertItem(int(currIndex), item) self.fileListWidget.insertItem(int(currIndex), item)
self.openNextImg() self.openNextImg()
self.actions.saveRec.setEnabled(True) self.actions.saveRec.setEnabled(True)
self.actions.saveLabel.setEnabled(True)
elif mode == 'Auto': elif mode == 'Auto':
if annotationFilePath and self.saveLabels(annotationFilePath, mode=mode): if annotationFilePath and self.saveLabels(annotationFilePath, mode=mode):
...@@ -1643,7 +1677,8 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1643,7 +1677,8 @@ class MainWindow(QMainWindow, WindowMixin):
self.setDirty() self.setDirty()
def deleteSelectedShape(self): def deleteSelectedShape(self):
self.remLabel(self.canvas.deleteSelected()) self.remLabels(self.canvas.deleteSelected())
self.actions.undo.setEnabled(True)
self.setDirty() self.setDirty()
if self.noShapes(): if self.noShapes():
for action in self.actions.onShapesPresent: for action in self.actions.onShapesPresent:
...@@ -1653,7 +1688,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1653,7 +1688,7 @@ class MainWindow(QMainWindow, WindowMixin):
color = self.colorDialog.getColor(self.lineColor, u'Choose line color', color = self.colorDialog.getColor(self.lineColor, u'Choose line color',
default=DEFAULT_LINE_COLOR) default=DEFAULT_LINE_COLOR)
if color: if color:
self.canvas.selectedShape.line_color = color for shape in self.canvas.selectedShapes: shape.line_color = color
self.canvas.update() self.canvas.update()
self.setDirty() self.setDirty()
...@@ -1661,7 +1696,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1661,7 +1696,7 @@ class MainWindow(QMainWindow, WindowMixin):
color = self.colorDialog.getColor(self.fillColor, u'Choose fill color', color = self.colorDialog.getColor(self.fillColor, u'Choose fill color',
default=DEFAULT_FILL_COLOR) default=DEFAULT_FILL_COLOR)
if color: if color:
self.canvas.selectedShape.fill_color = color for shape in self.canvas.selectedShapes: shape.fill_color = color
self.canvas.update() self.canvas.update()
self.setDirty() self.setDirty()
...@@ -1785,25 +1820,25 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1785,25 +1820,25 @@ class MainWindow(QMainWindow, WindowMixin):
def singleRerecognition(self): def singleRerecognition(self):
img = cv2.imread(self.filePath) img = cv2.imread(self.filePath)
shape = self.canvas.selectedShape for shape in self.canvas.selectedShapes:
box = [[int(p.x()), int(p.y())] for p in shape.points] box = [[int(p.x()), int(p.y())] for p in shape.points]
assert len(box) == 4 assert len(box) == 4
img_crop = get_rotate_crop_image(img, np.array(box, np.float32)) img_crop = get_rotate_crop_image(img, np.array(box, np.float32))
if img_crop is None: if img_crop is None:
msg = 'Can not recognise the detection box in ' + self.filePath + '. Please change manually' msg = 'Can not recognise the detection box in ' + self.filePath + '. Please change manually'
QMessageBox.information(self, "Information", msg) QMessageBox.information(self, "Information", msg)
return return
result = self.ocr.ocr(img_crop, cls=True, det=False) result = self.ocr.ocr(img_crop, cls=True, det=False)
if result[0][0] != '': if result[0][0] != '':
result.insert(0, box) result.insert(0, box)
print('result in reRec is ', result) print('result in reRec is ', result)
if result[1][0] == shape.label: if result[1][0] == shape.label:
print('label no change') print('label no change')
else: else:
shape.label = result[1][0] shape.label = result[1][0]
self.singleLabel(shape) self.singleLabel(shape)
self.setDirty() self.setDirty()
print(box) print(box)
def autolcm(self): def autolcm(self):
vbox = QVBoxLayout() vbox = QVBoxLayout()
...@@ -1914,8 +1949,8 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1914,8 +1949,8 @@ class MainWindow(QMainWindow, WindowMixin):
self.savePPlabel() self.savePPlabel()
def saveRecResult(self): def saveRecResult(self):
if None in [self.PPlabelpath, self.PPlabel, self.fileStatedict]: if {} in [self.PPlabelpath, self.PPlabel, self.fileStatedict]:
QMessageBox.information(self, "Information", "Save file first") QMessageBox.information(self, "Information", "Check the image first")
return return
rec_gt_dir = os.path.dirname(self.PPlabelpath) + '/rec_gt.txt' rec_gt_dir = os.path.dirname(self.PPlabelpath) + '/rec_gt.txt'
...@@ -1953,6 +1988,33 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1953,6 +1988,33 @@ class MainWindow(QMainWindow, WindowMixin):
self.canvas.newShape.disconnect() self.canvas.newShape.disconnect()
self.canvas.newShape.connect(partial(self.newShape, False)) self.canvas.newShape.connect(partial(self.newShape, False))
def autoSaveFunc(self):
if self.autoSaveOption.isChecked():
self.autoSaveNum = 1 # Real auto_Save
try:
self.saveLabelFile()
except:
pass
print('The program will automatically save once after confirming an image')
else:
self.autoSaveNum = 5 # Used for backup
print('The program will automatically save once after confirming 5 images (default)')
def undoShapeEdit(self):
self.canvas.restoreShape()
self.labelList.clear()
self.BoxList.clear()
self.loadShapes(self.canvas.shapes)
self.actions.undo.setEnabled(self.canvas.isShapeRestorable)
def loadShapes(self, shapes, replace=True):
self._noSelectionSlot = True
for shape in shapes:
self.addLabel(shape)
self.labelList.clearSelection()
self._noSelectionSlot = False
self.canvas.loadShapes(shapes, replace=replace)
def inverted(color): def inverted(color):
return QColor(*[255 - v for v in color.getRgb()]) return QColor(*[255 - v for v in color.getRgb()])
......
...@@ -8,6 +8,10 @@ PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, w ...@@ -8,6 +8,10 @@ PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, w
### Recent Update ### Recent Update
- 2021.2.5: New batch processing and undo functions (by [Evezerest](https://github.com/Evezerest)):
- Batch processing function: Press and hold the Ctrl key to select the box, you can move, copy, and delete in batches.
- Undo function: In the process of drawing a four-point label box or after editing the box, press Ctrl+Z to undo the previous operation.
- Fix image rotation and size problems, optimize the process of editing the mark frame (by [ninetailskim](https://github.com/ninetailskim)[edencfc](https://github.com/edencfc)).
- 2021.1.11: Optimize the labeling experience (by [edencfc](https://github.com/edencfc)), - 2021.1.11: Optimize the labeling experience (by [edencfc](https://github.com/edencfc)),
- Users can choose whether to pop up the label input dialog after drawing the detection box in "View - Pop-up Label Input Dialog". - Users can choose whether to pop up the label input dialog after drawing the detection box in "View - Pop-up Label Input Dialog".
- The recognition result scrolls synchronously when users click related detection box. - The recognition result scrolls synchronously when users click related detection box.
...@@ -16,7 +20,6 @@ PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, w ...@@ -16,7 +20,6 @@ PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, w
### TODO: ### TODO:
- Lock box mode: For the same scene data, the size and position of the locked detection box can be transferred between different pictures. - Lock box mode: For the same scene data, the size and position of the locked detection box can be transferred between different pictures.
- Experience optimization: Add undo, batch operation include move, copy, delete and so on, optimize the annotation process.
## Installation ## Installation
...@@ -76,12 +79,11 @@ python3 PPOCRLabel.py ...@@ -76,12 +79,11 @@ python3 PPOCRLabel.py
7. Double click the result in 'recognition result' list to manually change inaccurate recognition results. 7. Double click the result in 'recognition result' list to manually change inaccurate recognition results.
8. Click "Check", the image status will switch to "√",then the program automatically jump to the next(The results will not be written directly to the file at this time). 8. Click "Check", the image status will switch to "√",then the program automatically jump to the next.
9. Click "Delete Image" and the image will be deleted to the recycle bin. 9. Click "Delete Image" and the image will be deleted to the recycle bin.
10. Labeling result: the user can save manually through the menu "File - Save Label", while the program will also save automatically after every 5 images confirmed by the user.the manually checked label will be stored in *Label.txt* under the opened picture folder. 10. Labeling result: the user can save manually through the menu "File - Save Label", while the program will also save automatically if "File - Auto Save Label Mode" is selected. The manually checked label will be stored in *Label.txt* under the opened picture folder. Click "PaddleOCR"-"Save Recognition Results" in the menu bar, the recognition training data of such pictures will be saved in the *crop_img* folder, and the recognition label will be saved in *rec_gt.txt*<sup>[4]</sup>.
Click "PaddleOCR"-"Save Recognition Results" in the menu bar, the recognition training data of such pictures will be saved in the *crop_img* folder, and the recognition label will be saved in *rec_gt.txt*<sup>[4]</sup>.
### Note ### Note
...@@ -89,8 +91,7 @@ python3 PPOCRLabel.py ...@@ -89,8 +91,7 @@ python3 PPOCRLabel.py
[2] The image status indicates whether the user has saved the image manually. If it has not been saved manually it is "X", otherwise it is "√", PPOCRLabel will not relabel pictures with a status of "√". [2] The image status indicates whether the user has saved the image manually. If it has not been saved manually it is "X", otherwise it is "√", PPOCRLabel will not relabel pictures with a status of "√".
[3] After clicking "Re-recognize", the model will overwrite ALL recognition results in the picture. [3] After clicking "Re-recognize", the model will overwrite ALL recognition results in the picture. Therefore, if the recognition result has been manually changed before, it may change after re-recognition.
Therefore, if the recognition result has been manually changed before, it may change after re-recognition.
[4] The files produced by PPOCRLabel can be found under the opened picture folder including the following, please do not manually change the contents, otherwise it will cause the program to be abnormal. [4] The files produced by PPOCRLabel can be found under the opened picture folder including the following, please do not manually change the contents, otherwise it will cause the program to be abnormal.
...@@ -106,22 +107,23 @@ Therefore, if the recognition result has been manually changed before, it may ch ...@@ -106,22 +107,23 @@ Therefore, if the recognition result has been manually changed before, it may ch
### Shortcut keys ### Shortcut keys
| Shortcut keys | Description | | Shortcut keys | Description |
| ---------------- | ------------------------------------------------ | | ------------------------ | ------------------------------------------------ |
| Ctrl + shift + A | Automatically label all unchecked images | | Ctrl + Shift + R | Re-recognize all the labels of the current image |
| Ctrl + shift + R | Re-recognize all the labels of the current image | | W | Create a rect box |
| W | Create a rect box | | Q | Create a four-points box |
| Q | Create a four-points box | | Ctrl + E | Edit label of the selected box |
| Ctrl + E | Edit label of the selected box | | Ctrl + R | Re-recognize the selected box |
| Ctrl + R | Re-recognize the selected box | | Ctrl + C | Copy and paste the selected box |
| Backspace | Delete the selected box | | Ctrl + Left Mouse Button | Multi select the label box |
| Ctrl + V | Check image | | Backspace | Delete the selected box |
| Ctrl + Shift + d | Delete image | | Ctrl + V | Check image |
| D | Next image | | Ctrl + Shift + d | Delete image |
| A | Previous image | | D | Next image |
| Ctrl++ | Zoom in | | A | Previous image |
| Ctrl-- | Zoom out | | Ctrl++ | Zoom in |
| ↑→↓← | Move selected box | | Ctrl-- | Zoom out |
| ↑→↓← | Move selected box |
### Built-in Model ### Built-in Model
...@@ -136,7 +138,7 @@ Therefore, if the recognition result has been manually changed before, it may ch ...@@ -136,7 +138,7 @@ Therefore, if the recognition result has been manually changed before, it may ch
PPOCRLabel supports three ways to save Label.txt PPOCRLabel supports three ways to save Label.txt
- Automatically save: When it detects that the user has manually checked 5 pictures, the program automatically writes the annotations into Label.txt. The user can change the value of ``self.autoSaveNum`` in ``PPOCRLabel.py`` to set the number of images to be automatically saved after confirmation. - Automatically save: After selecting "File - Auto Save Label Mode", the program will automatically write the annotations into Label.txt every time the user confirms an image. If this option is not turned on, it will be automatically saved after detecting that the user has manually checked 5 images.
- Manual save: Click "File-Save Marking Results" to manually save the label. - Manual save: Click "File-Save Marking Results" to manually save the label.
- Close application save - Close application save
...@@ -167,4 +169,4 @@ For some data that are difficult to recognize, the recognition results will not ...@@ -167,4 +169,4 @@ For some data that are difficult to recognize, the recognition results will not
### Related ### Related
1.[Tzutalin. LabelImg. Git code (2015)](https://github.com/tzutalin/labelImg) 1.[Tzutalin. LabelImg. Git code (2015)](https://github.com/tzutalin/labelImg)
\ No newline at end of file
...@@ -8,6 +8,10 @@ PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置P ...@@ -8,6 +8,10 @@ PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置P
#### 近期更新 #### 近期更新
- 2021.2.5:新增批处理与撤销功能(by [Evezerest](https://github.com/Evezerest))
- 批处理功能:按住Ctrl键选择标记框后可批量移动、复制、删除。
- 撤销功能:在绘制四点标注框过程中或对框进行编辑操作后,按下Ctrl+Z可撤销上一部操作。
- 修复图像旋转和尺寸问题、优化编辑标记框过程(by [ninetailskim](https://github.com/ninetailskim)[edencfc](https://github.com/edencfc)
- 2021.1.11:优化标注体验(by [edencfc](https://github.com/edencfc)): - 2021.1.11:优化标注体验(by [edencfc](https://github.com/edencfc)):
- 用户可在“视图 - 弹出标记输入框”选择在画完检测框后标记输入框是否弹出。 - 用户可在“视图 - 弹出标记输入框”选择在画完检测框后标记输入框是否弹出。
- 识别结果与检测框同步滚动。 - 识别结果与检测框同步滚动。
...@@ -17,9 +21,8 @@ PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置P ...@@ -17,9 +21,8 @@ PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置P
#### 尽请期待 #### 尽请期待
- 锁定框模式:针对同一场景数据,被锁定的检测框的大小与位置能在不同图片之间传递。 - 锁定框模式:针对同一场景数据,被锁定的检测框的大小与位置能在不同图片之间传递。
- 体验优化:增加撤销操作,批量移动、复制、删除等功能。优化标注流程。
如果您对以上内容感兴趣或对完善工具有不一样的想法,欢迎加入我们的队伍与我们共同开发 如果您对以上内容感兴趣或对完善工具有不一样的想法,欢迎加入我们的SIG队伍与我们共同开发。可以在[此处](https://github.com/PaddlePaddle/PaddleOCR/issues/1728)完成问卷和前置任务,经过我们确认相关内容后即可正式加入,享受SIG福利,共同为OCR开源事业贡献(特别说明:针对PPOCRLabel的改进也属于PaddleOCR前置任务)
## 安装 ## 安装
...@@ -65,9 +68,9 @@ python3 PPOCRLabel.py --lang ch ...@@ -65,9 +68,9 @@ python3 PPOCRLabel.py --lang ch
5. 标记框绘制完成后,用户点击 “确认”,检测框会先被预分配一个 “待识别” 标签。 5. 标记框绘制完成后,用户点击 “确认”,检测框会先被预分配一个 “待识别” 标签。
6. 重新识别:将图片中的所有检测画绘制/调整完成后,点击 “重新识别”,PPOCR模型会对当前图片中的**所有检测框**重新识别<sup>[3]</sup> 6. 重新识别:将图片中的所有检测画绘制/调整完成后,点击 “重新识别”,PPOCR模型会对当前图片中的**所有检测框**重新识别<sup>[3]</sup>
7. 内容更改:双击识别结果,对不准确的识别结果进行手动更改。 7. 内容更改:双击识别结果,对不准确的识别结果进行手动更改。
8. 确认标记:点击 “确认”,图片状态切换为 “√”,跳转至下一张(此时不会直接将结果写入文件) 8. **确认标记**:点击 “确认”,图片状态切换为 “√”,跳转至下一张
9. 删除:点击 “删除图像”,图片将会被删除至回收站。 9. 删除:点击 “删除图像”,图片将会被删除至回收站。
10. 保存结果:用户可以通过菜单中“文件-保存标记结果”手动保存,同时程序也会在用户每确认5张图片后自动保存一次。手动确认过的标记将会被存放在所打开图片文件夹下的*Label.txt*中。在菜单栏点击 “文件” - "保存识别结果"后,会将此类图片的识别训练数据保存在*crop_img*文件夹下,识别标签保存在*rec_gt.txt*<sup>[4]</sup> 10. 保存结果:用户可以通过菜单中“文件-保存标记结果”手动保存,同时也可以点击“文件 - 自动保存标记结果”开启自动保存。手动确认过的标记将会被存放在所打开图片文件夹下的*Label.txt*中。在菜单栏点击 “文件” - "保存识别结果"后,会将此类图片的识别训练数据保存在*crop_img*文件夹下,识别标签保存在*rec_gt.txt*<sup>[4]</sup>
### 注意 ### 注意
...@@ -93,12 +96,13 @@ python3 PPOCRLabel.py --lang ch ...@@ -93,12 +96,13 @@ python3 PPOCRLabel.py --lang ch
| 快捷键 | 说明 | | 快捷键 | 说明 |
| ---------------- | ---------------------------- | | ---------------- | ---------------------------- |
| Ctrl + shift + A | 自动标注所有未确认过的图片 |
| Ctrl + shift + R | 对当前图片的所有标记重新识别 | | Ctrl + shift + R | 对当前图片的所有标记重新识别 |
| W | 新建矩形框 | | W | 新建矩形框 |
| Q | 新建四点框 | | Q | 新建四点框 |
| Ctrl + E | 编辑所选框标签 | | Ctrl + E | 编辑所选框标签 |
| Ctrl + R | 重新识别所选标记 | | Ctrl + R | 重新识别所选标记 |
| Ctrl + C | 复制并粘贴选中的标记框 |
| Ctrl + 鼠标左键 | 多选标记框 |
| Backspace | 删除所选框 | | Backspace | 删除所选框 |
| Ctrl + V | 确认本张图片标记 | | Ctrl + V | 确认本张图片标记 |
| Ctrl + Shift + d | 删除本张图片 | | Ctrl + Shift + d | 删除本张图片 |
...@@ -120,7 +124,7 @@ python3 PPOCRLabel.py --lang ch ...@@ -120,7 +124,7 @@ python3 PPOCRLabel.py --lang ch
PPOCRLabel支持三种保存方式: PPOCRLabel支持三种保存方式:
- 程序自动保存:当检测到用户手动确认过5张图片后,程序自动将标记结果写入Label.txt中。其中用户可通过更改```PPOCRLabel.py```中的```self.autoSaveNum```的数值设置确认几张图片后进行自动保存。 - 自动保存:点击“文件 - 自动保存标记结果”后,用户每确认过一张图片,程序自动将标记结果写入Label.txt中。若未开启此选项,则检测到用户手动确认过5张图片后进行自动保存。
- 手动保存:点击“文件 - 保存标记结果”手动保存标记。 - 手动保存:点击“文件 - 保存标记结果”手动保存标记。
- 关闭应用程序保存 - 关闭应用程序保存
......
此差异已折叠。
此差异已折叠。
...@@ -82,7 +82,7 @@ class Shape(object): ...@@ -82,7 +82,7 @@ class Shape(object):
return False return False
def addPoint(self, point): def addPoint(self, point):
if not self.reachMaxPoints(): if not self.reachMaxPoints(): # 4个点时发出close信号
self.points.append(point) self.points.append(point)
def popPoint(self): def popPoint(self):
......
...@@ -96,4 +96,7 @@ hideBox=隐藏所有标注 ...@@ -96,4 +96,7 @@ hideBox=隐藏所有标注
showBox=显示所有标注 showBox=显示所有标注
saveLabel=保存标记结果 saveLabel=保存标记结果
singleRe=重识别此区块 singleRe=重识别此区块
labelDialogOption=弹出标记输入框 labelDialogOption=弹出标记输入框
\ No newline at end of file undo=撤销
undoLastPoint=撤销上个点
autoSaveMode=自动保存标记结果
\ No newline at end of file
...@@ -96,4 +96,7 @@ hideBox=Hide All Box ...@@ -96,4 +96,7 @@ hideBox=Hide All Box
showBox=Show All Box showBox=Show All Box
saveLabel=Save Label saveLabel=Save Label
singleRe=Re-recognition RectBox singleRe=Re-recognition RectBox
labelDialogOption=Pop-up Label Input Dialog labelDialogOption=Pop-up Label Input Dialog
\ No newline at end of file undo=Undo
undoLastPoint=Undo Last Point
autoSaveMode=Auto Save Label Mode
\ No newline at end of file
doc/joinus.PNG

111.0 KB | W: | H:

doc/joinus.PNG

109.2 KB | W: | H:

doc/joinus.PNG
doc/joinus.PNG
doc/joinus.PNG
doc/joinus.PNG
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册