diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index aeed6435a4e84b2b58811e9087d9713300848104..827f1cf76846d0e232e980bc21f45ae0cd1a640b 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -28,7 +28,7 @@ from PyQt5.QtCore import QSize, Qt, QPoint, QByteArray, QTimer, QFileInfo, QPoin from PyQt5.QtGui import QImage, QCursor, QPixmap, QImageReader from PyQt5.QtWidgets import QMainWindow, QListWidget, QVBoxLayout, QToolButton, QHBoxLayout, QDockWidget, QWidget, \ QSlider, QGraphicsOpacityEffect, QMessageBox, QListView, QScrollArea, QWidgetAction, QApplication, QLabel, QGridLayout, \ - QFileDialog, QListWidgetItem, QComboBox, QDialog, QAbstractItemView + QFileDialog, QListWidgetItem, QComboBox, QDialog, QAbstractItemView, QSizePolicy __dir__ = os.path.dirname(os.path.abspath(__file__)) @@ -227,6 +227,21 @@ class MainWindow(QMainWindow): listLayout.addWidget(leftTopToolBoxContainer) # ================== Label List ================== + labelIndexListlBox = QHBoxLayout() + + # Create and add a widget for showing current label item index + self.indexList = QListWidget() + self.indexList.setMaximumSize(30, 16777215) # limit max width + self.indexList.setEditTriggers(QAbstractItemView.NoEditTriggers) # no editable + self.indexList.itemSelectionChanged.connect(self.indexSelectionChanged) + self.indexList.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # no scroll Bar + self.indexListDock = QDockWidget('No.', self) + self.indexListDock.setWidget(self.indexList) + self.indexListDock.setFeatures(QDockWidget.NoDockWidgetFeatures) + labelIndexListlBox.addWidget(self.indexListDock, 1) + # no margin between two boxes + labelIndexListlBox.setSpacing(0) + # Create and add a widget for showing current label items self.labelList = EditInList() labelListContainer = QWidget() @@ -240,8 +255,8 @@ class MainWindow(QMainWindow): self.labelListDock = QDockWidget(self.labelListDockName, self) self.labelListDock.setWidget(self.labelList) self.labelListDock.setFeatures(QDockWidget.NoDockWidgetFeatures) - listLayout.addWidget(self.labelListDock) - + labelIndexListlBox.addWidget(self.labelListDock, 10) # label list is wider than index list + # enable labelList drag_drop to adjust bbox order # 设置选择模式为单选 self.labelList.setSelectionMode(QAbstractItemView.SingleSelection) @@ -256,6 +271,17 @@ class MainWindow(QMainWindow): # 触发放置 self.labelList.model().rowsMoved.connect(self.drag_drop_happened) + labelIndexListContainer = QWidget() + labelIndexListContainer.setLayout(labelIndexListlBox) + listLayout.addWidget(labelIndexListContainer) + + # labelList indexList同步滚动 + self.labelListBar = self.labelList.verticalScrollBar() + self.indexListBar = self.indexList.verticalScrollBar() + + self.labelListBar.valueChanged.connect(self.move_scrollbar) + self.indexListBar.valueChanged.connect(self.move_scrollbar) + # ================== Detection Box ================== self.BoxList = QListWidget() @@ -766,6 +792,7 @@ class MainWindow(QMainWindow): self.shapesToItemsbox.clear() self.labelList.clear() self.BoxList.clear() + self.indexList.clear() self.filePath = None self.imageData = None self.labelFile = None @@ -1027,13 +1054,19 @@ class MainWindow(QMainWindow): for shape in self.canvas.selectedShapes: shape.selected = False self.labelList.clearSelection() + self.indexList.clearSelection() self.canvas.selectedShapes = selected_shapes for shape in self.canvas.selectedShapes: shape.selected = True self.shapesToItems[shape].setSelected(True) self.shapesToItemsbox[shape].setSelected(True) + index = self.labelList.indexFromItem(self.shapesToItems[shape]).row() + self.indexList.item(index).setSelected(True) self.labelList.scrollToItem(self.currentItem()) # QAbstractItemView.EnsureVisible + # map current label item to index item and select it + index = self.labelList.indexFromItem(self.currentItem()).row() + self.indexList.scrollToItem(self.indexList.item(index)) self.BoxList.scrollToItem(self.currentBox()) if self.kie_mode: @@ -1066,12 +1099,18 @@ class MainWindow(QMainWindow): shape.paintIdx = self.displayIndexOption.isChecked() item = HashableQListWidgetItem(shape.label) - item.setFlags(item.flags() | Qt.ItemIsUserCheckable) - item.setCheckState(Qt.Unchecked) if shape.difficult else item.setCheckState(Qt.Checked) + # current difficult checkbox is disenble + # item.setFlags(item.flags() | Qt.ItemIsUserCheckable) + # item.setCheckState(Qt.Unchecked) if shape.difficult else item.setCheckState(Qt.Checked) + # Checked means difficult is False # item.setBackground(generateColorByText(shape.label)) self.itemsToShapes[item] = shape self.shapesToItems[shape] = item + # add current label item index before label string + current_index = QListWidgetItem(str(self.labelList.count())) + current_index.setTextAlignment(Qt.AlignHCenter) + self.indexList.addItem(current_index) self.labelList.addItem(item) # print('item in add label is ',[(p.x(), p.y()) for p in shape.points], shape.label) @@ -1105,6 +1144,7 @@ class MainWindow(QMainWindow): del self.shapesToItemsbox[shape] del self.itemsToShapesbox[item] self.updateComboBox() + self.updateIndexList() def loadLabels(self, shapes): s = [] @@ -1156,6 +1196,13 @@ class MainWindow(QMainWindow): # self.comboBox.update_items(uniqueTextList) + def updateIndexList(self): + self.indexList.clear() + for i in range(self.labelList.count()): + string = QListWidgetItem(str(i)) + string.setTextAlignment(Qt.AlignHCenter) + self.indexList.addItem(string) + def saveLabels(self, annotationFilePath, mode='Auto'): # Mode is Auto means that labels will be loaded from self.result_dic totally, which is the output of ocr model annotationFilePath = ustr(annotationFilePath) @@ -1211,6 +1258,10 @@ class MainWindow(QMainWindow): # fix copy and delete # self.shapeSelectionChanged(True) + def move_scrollbar(self, value): + self.labelListBar.setValue(value) + self.indexListBar.setValue(value) + def labelSelectionChanged(self): if self._noSelectionSlot: return @@ -1223,6 +1274,21 @@ class MainWindow(QMainWindow): else: self.canvas.deSelectShape() + def indexSelectionChanged(self): + if self._noSelectionSlot: + return + if self.canvas.editing(): + selected_shapes = [] + for item in self.indexList.selectedItems(): + # map index item to label item + index = self.indexList.indexFromItem(item).row() + item = self.labelList.item(index) + selected_shapes.append(self.itemsToShapes[item]) + if selected_shapes: + self.canvas.selectShapes(selected_shapes) + else: + self.canvas.deSelectShape() + def boxSelectionChanged(self): if self._noSelectionSlot: # self.BoxList.scrollToItem(self.currentBox(), QAbstractItemView.PositionAtCenter) @@ -1517,6 +1583,7 @@ class MainWindow(QMainWindow): if self.labelList.count(): self.labelList.setCurrentItem(self.labelList.item(self.labelList.count() - 1)) self.labelList.item(self.labelList.count() - 1).setSelected(True) + self.indexList.item(self.labelList.count() - 1).setSelected(True) # show file list image count select_indexes = self.fileListWidget.selectedIndexes() @@ -2015,12 +2082,14 @@ class MainWindow(QMainWindow): for shape in self.canvas.shapes: shape.paintLabel = self.displayLabelOption.isChecked() shape.paintIdx = self.displayIndexOption.isChecked() + self.canvas.repaint() def togglePaintIndexOption(self): self.displayLabelOption.setChecked(False) for shape in self.canvas.shapes: shape.paintLabel = self.displayLabelOption.isChecked() shape.paintIdx = self.displayIndexOption.isChecked() + self.canvas.repaint() def toogleDrawSquare(self): self.canvas.setDrawingShapeToSquare(self.drawSquaresOption.isChecked()) @@ -2254,6 +2323,7 @@ class MainWindow(QMainWindow): self.itemsToShapesbox.clear() # ADD self.shapesToItemsbox.clear() self.labelList.clear() + self.indexList.clear() self.BoxList.clear() self.result_dic = [] self.result_dic_locked = [] @@ -2665,6 +2735,7 @@ class MainWindow(QMainWindow): def undoShapeEdit(self): self.canvas.restoreShape() self.labelList.clear() + self.indexList.clear() self.BoxList.clear() self.loadShapes(self.canvas.shapes) self.actions.undo.setEnabled(self.canvas.isShapeRestorable) @@ -2674,6 +2745,7 @@ class MainWindow(QMainWindow): for shape in shapes: self.addLabel(shape) self.labelList.clearSelection() + self.indexList.clearSelection() self._noSelectionSlot = False self.canvas.loadShapes(shapes, replace=replace) print("loadShapes") # 1 diff --git a/PPOCRLabel/README.md b/PPOCRLabel/README.md index 368a835c203f62d529bb874b3cbbf7593b96a8ba..3bdc336827adb87f52e9baa2c012304595b2c656 100644 --- a/PPOCRLabel/README.md +++ b/PPOCRLabel/README.md @@ -2,7 +2,7 @@ English | [简体中文](README_ch.md) # PPOCRLabel -PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, with built-in PPOCR model to automatically detect and re-recognize data. It is written in python3 and pyqt5, supporting rectangular box, table and multi-point annotation modes. Annotations can be directly used for the training of PPOCR detection and recognition models. +PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, with built-in PP-OCR model to automatically detect and re-recognize data. It is written in python3 and pyqt5, supporting rectangular box, table and multi-point annotation modes. Annotations can be directly used for the training of PP-OCR detection and recognition models. @@ -142,14 +142,18 @@ In PPOCRLabel, complete the text information labeling (text and position), compl labeling in the Excel file, the recommended steps are: 1. Table annotation: After opening the table picture, click on the `Table Recognition` button in the upper right corner of PPOCRLabel, which will call the table recognition model in PP-Structure to automatically label -the table and pop up Excel at the same time. - + the table and pop up Excel at the same time. + 2. Change the recognition result: **label each cell** (i.e. the text in a cell is marked as a box). Right click on the box and click on `Cell Re-recognition`. You can use the model to automatically recognise the text within a cell. - + 3. Mark the table structure: for each cell contains the text, **mark as any identifier (such as `1`) in Excel**, to ensure that the merged cell structure is same as the original picture. -4. Export JSON format annotation: close all Excel files corresponding to table images, click `File`-`Export table JSON annotation` to obtain JSON annotation results. + > Note: If there are blank cells in the table, you also need to mark them with a bounding box so that the total number of cells is the same as in the image. + +4. ***Adjust cell order:*** Click on the menu `View` - `Show Box Number` to show the box ordinal numbers, and drag all the results under the 'Recognition Results' column on the right side of the software interface to make the box numbers are arranged from left to right, top to bottom + +5. Export JSON format annotation: close all Excel files corresponding to table images, click `File`-`Export table JSON annotation` to obtain JSON annotation results. ### 2.3 Note @@ -219,14 +223,7 @@ PPOCRLabel supports three ways to export Label.txt - Close application export - -### 3.4 Export Partial Recognition Results - -For some data that are difficult to recognize, the recognition results will not be exported by **unchecking** the corresponding tags in the recognition results checkbox. The unchecked recognition result is saved as `True` in the `difficult` variable in the label file `label.txt`. - -> *Note: The status of the checkboxes in the recognition results still needs to be saved manually by clicking Save Button.* - -### 3.5 Dataset division +### 3.4 Dataset division - Enter the following command in the terminal to execute the dataset division script: @@ -255,7 +252,7 @@ For some data that are difficult to recognize, the recognition results will not | ... ``` -### 3.6 Error message +### 3.5 Error message - If paddleocr is installed with whl, it has a higher priority than calling PaddleOCR class with paddleocr.py, which may cause an exception if whl package is not updated. diff --git a/PPOCRLabel/README_ch.md b/PPOCRLabel/README_ch.md index 9b90ec3f09aea9b383744eadf483263e45e1fb73..800ef14004d561045b13bcdf727d813486f24cb3 100644 --- a/PPOCRLabel/README_ch.md +++ b/PPOCRLabel/README_ch.md @@ -7,8 +7,8 @@ PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置P #### 近期更新 -- 2022.05:新增表格标注,使用方法见下方`2.2 表格标注`(by [whjdark](https://github.com/peterh0323); [Evezerest](https://github.com/Evezerest)) -- 2022.02:新增关键信息标注、优化标注体验(by [PeterH0323](https://github.com/peterh0323) ) +- 2022.05:**新增表格标注**,使用方法见下方`2.2 表格标注`(by [whjdark](https://github.com/peterh0323); [Evezerest](https://github.com/Evezerest)) +- 2022.02:**新增关键信息标注**、优化标注体验(by [PeterH0323](https://github.com/peterh0323) ) - 新增:使用 `--kie` 进入 KIE 功能,用于打【检测+识别+关键字提取】的标签 - 提升用户体验:新增文件与标记数目提示、优化交互、修复gpu使用等问题。 - 新增功能:使用 `C` 和 `X` 对标记框进行旋转。 @@ -113,23 +113,29 @@ pip3 install dist/PPOCRLabel-1.0.2-py2.py3-none-any.whl -i https://mirror.baidu. 1. 安装与运行:使用上述命令安装与运行程序。 2. 打开文件夹:在菜单栏点击 “文件” - "打开目录" 选择待标记图片的文件夹[1]. -3. 自动标注:点击 ”自动标注“,使用PPOCR超轻量模型对图片文件名前图片状态[2]为 “X” 的图片进行自动标注。 +3. 自动标注:点击 ”自动标注“,使用PP-OCR超轻量模型对图片文件名前图片状态[2]为 “X” 的图片进行自动标注。 4. 手动标注:点击 “矩形标注”(推荐直接在英文模式下点击键盘中的 “W”),用户可对当前图片中模型未检出的部分进行手动绘制标记框。点击键盘Q,则使用四点标注模式(或点击“编辑” - “四点标注”),用户依次点击4个点后,双击左键表示标注完成。 5. 标记框绘制完成后,用户点击 “确认”,检测框会先被预分配一个 “待识别” 标签。 -6. 重新识别:将图片中的所有检测画绘制/调整完成后,点击 “重新识别”,PPOCR模型会对当前图片中的**所有检测框**重新识别[3]。 +6. 重新识别:将图片中的所有检测画绘制/调整完成后,点击 “重新识别”,PP-OCR模型会对当前图片中的**所有检测框**重新识别[3]。 7. 内容更改:单击识别结果,对不准确的识别结果进行手动更改。 8. **确认标记:点击 “确认”,图片状态切换为 “√”,跳转至下一张。** 9. 删除:点击 “删除图像”,图片将会被删除至回收站。 10. 导出结果:用户可以通过菜单中“文件-导出标记结果”手动导出,同时也可以点击“文件 - 自动导出标记结果”开启自动导出。手动确认过的标记将会被存放在所打开图片文件夹下的*Label.txt*中。在菜单栏点击 “文件” - "导出识别结果"后,会将此类图片的识别训练数据保存在*crop_img*文件夹下,识别标签保存在*rec_gt.txt*中[4]。 ### 2.2 表格标注 -表格标注针对表格的结构化提取,将图片中的表格转换为Excel格式,因此标注时需要配合外部软件打开Excel同时完成。 -在PPOCRLabel软件中完成表格中的文字信息标注(文字与位置)、在Excel文件中完成表格结构信息标注,推荐的步骤为: +表格标注针对表格的结构化提取,将图片中的表格转换为Excel格式,因此标注时需要配合外部软件打开Excel同时完成。在PPOCRLabel软件中完成表格中的文字信息标注(文字与位置)、在Excel文件中完成表格结构信息标注,推荐的步骤为: 1. 表格识别:打开表格图片后,点击软件右上角 `表格识别` 按钮,软件调用PP-Structure中的表格识别模型,自动为表格打标签,同时弹出Excel -2. 更改识别结果:**以表格中的单元格为单位增加标注框**(即一个单元格内的文字都标记为一个框)。标注框上鼠标右键后点击 `单元格重识别` + +2. 更改标注结果:**以表格中的单元格为单位增加标注框**(即一个单元格内的文字都标记为一个框)。标注框上鼠标右键后点击 `单元格重识别` 可利用模型自动识别单元格内的文字。 -3. 标注表格结构:将表格图像中有文字的单元格,**在Excel中标记为任意标识符(如`1`)**,保证Excel中的单元格合并情况与原图相同即可。 -4. 导出JSON格式:关闭所有表格图像对应的Excel,点击 `文件`-`导出表格JSON标注` 获得JSON标注结果。 + + > 注意:如果表格中存在空白单元格,同样需要使用一个标注框将其标出,使得单元格总数与图像中保持一致。 + +3. **调整单元格顺序:**点击软件`视图-显示框编号` 打开标注框序号,在软件界面右侧拖动 `识别结果` 一栏下的所有结果,使得标注框编号按照从左到右,从上到下的顺序排列 + +4. 标注表格结构:**在外部Excel软件中,将存在文字的单元格标记为任意标识符(如 `1` )**,保证Excel中的单元格合并情况与原图相同即可(即不需要Excel中的单元格文字与图片中的文字完全相同) + +5. 导出JSON格式:关闭所有表格图像对应的Excel,点击 `文件`-`导出表格JSON标注` 获得JSON标注结果。 ### 2.3 注意 @@ -197,13 +203,7 @@ PPOCRLabel支持三种导出方式: - 关闭应用程序导出 -### 3.4 导出部分识别结果 - -针对部分难以识别的数据,通过在识别结果的复选框中**取消勾选**相应的标记,其识别结果不会被导出。被取消勾选的识别结果在标记文件 `label.txt` 中的 `difficult` 变量保存为 `True` 。 - -> *注意:识别结果中的复选框状态仍需用户手动点击确认后才能保留* - -### 3.5 数据集划分 +### 3.4 数据集划分 在终端中输入以下命令执行数据集划分脚本: @@ -232,7 +232,7 @@ python gen_ocr_train_val_test.py --trainValTestRatio 6:2:2 --datasetRootPath ../ | ... ``` -### 3.6 错误提示 +### 3.5 错误提示 - 如果同时使用whl包安装了paddleocr,其优先级大于通过paddleocr.py调用PaddleOCR类,whl包未更新时会导致程序异常。 diff --git a/PPOCRLabel/libs/canvas.py b/PPOCRLabel/libs/canvas.py index 81f37995126140b03650f5ddea37ea282d5ceb09..ae9511612a2ba83001c12ae8ed82498952207f98 100644 --- a/PPOCRLabel/libs/canvas.py +++ b/PPOCRLabel/libs/canvas.py @@ -627,7 +627,7 @@ class Canvas(QWidget): # adaptive BBOX label & index font size if self.pixmap: h, w = self.pixmap.size().height(), self.pixmap.size().width() - fontszie = int(max(h, w) / 48) + fontszie = int(max(h, w) / 96) for s in self.shapes: s.fontsize = fontszie diff --git a/PPOCRLabel/libs/shape.py b/PPOCRLabel/libs/shape.py index 121e43b8aee62dd3e5e0b2e2fbdebf10e775f57b..3eda5bdfa13b8c5369dec69bf803145e0fc3ce13 100644 --- a/PPOCRLabel/libs/shape.py +++ b/PPOCRLabel/libs/shape.py @@ -126,7 +126,7 @@ class Shape(object): color = self.select_line_color if self.selected else self.line_color pen = QPen(color) # Try using integer sizes for smoother drawing(?) - pen.setWidth(max(1, int(round(2.0 / self.scale)))) + # pen.setWidth(max(1, int(round(2.0 / self.scale)))) painter.setPen(pen) line_path = QPainterPath() diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index 6edf0b9194ee59143e287394f505b60010ec6644..2f39fbd232fa4bcab4cd30622d21c56d11a72d31 100644 --- a/configs/det/det_mv3_db.yml +++ b/configs/det/det_mv3_db.yml @@ -101,7 +101,7 @@ Train: drop_last: False batch_size_per_card: 16 num_workers: 8 - use_shared_memory: False + use_shared_memory: True Eval: dataset: @@ -129,4 +129,4 @@ Eval: drop_last: False batch_size_per_card: 1 # must be 1 num_workers: 8 - use_shared_memory: False + use_shared_memory: True diff --git a/configs/table/table_master.yml b/configs/table/table_master.yml index 1e6efe32dbc077e910a417a7616db7bcc7f7c825..b8daf3630755e61322665b6fc5f830e4a45875b8 100755 --- a/configs/table/table_master.yml +++ b/configs/table/table_master.yml @@ -104,7 +104,7 @@ Train: Eval: dataset: name: PubTabDataSet - data_dir: train_data/table/pubtabnet/train/ + data_dir: train_data/table/pubtabnet/val/ label_file_list: [train_data/table/pubtabnet/PubTabNet_2.0.0_val.jsonl] transforms: - DecodeImage: diff --git a/test_tipc/configs/ch_PP-OCRv2_det/train_infer_python.txt b/test_tipc/configs/ch_PP-OCRv2_det/train_infer_python.txt index cab0cb0aa390c7cb1efa6e5d3bc636e9c974acba..7a20df7f6c1e2eeee19f55cefa3320d34a62a701 100644 --- a/test_tipc/configs/ch_PP-OCRv2_det/train_infer_python.txt +++ b/test_tipc/configs/ch_PP-OCRv2_det/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_cml.yml -o +norm_train:tools/train.py -c configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_cml.yml -o Global.print_batch_step=1 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -51,3 +51,9 @@ null:null null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] +===========================train_benchmark_params========================== +batch_size:8 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml b/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml index 6c63af6ae8d62e098dec35d5918291291f654e32..a1497ba8fa4790a53cd602829edf3240ff8dc51a 100644 --- a/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml +++ b/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml @@ -6,7 +6,7 @@ Global: print_batch_step: 10 save_model_dir: ./output/rec_pp-OCRv2_distillation save_epoch_step: 3 - eval_batch_step: [0, 2000] + eval_batch_step: [0, 200000] cal_metric_during_train: true pretrained_model: checkpoints: @@ -114,7 +114,7 @@ Train: name: SimpleDataSet data_dir: ./train_data/ic15_data/ label_file_list: - - ./train_data/ic15_data/rec_gt_train.txt + - ./train_data/ic15_data/rec_gt_train4w.txt transforms: - DecodeImage: img_mode: BGR diff --git a/test_tipc/configs/ch_PP-OCRv2_rec/train_infer_python.txt b/test_tipc/configs/ch_PP-OCRv2_rec/train_infer_python.txt index df42b342ba5fa3947a69c2bde5548975ca92d857..a96b87dede1e1b4c7b3ed59c4bd9c0470402e7e2 100644 --- a/test_tipc/configs/ch_PP-OCRv2_rec/train_infer_python.txt +++ b/test_tipc/configs/ch_PP-OCRv2_rec/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./inference/rec_inference null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml -o +norm_train:tools/train.py -c test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml -o Global.print_batch_step=4 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -51,3 +51,9 @@ null:null null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,32,320]}] +===========================train_benchmark_params========================== +batch_size:64 +fp_items:fp32|fp16 +epoch:1 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/ch_PP-OCRv3_det/train_infer_python.txt b/test_tipc/configs/ch_PP-OCRv3_det/train_infer_python.txt index a69e0ab81ec6963228e9ab2e39c5bb1d730b6323..bf10aebe3e9aa67e30ce7a20cb07f376825e39ae 100644 --- a/test_tipc/configs/ch_PP-OCRv3_det/train_infer_python.txt +++ b/test_tipc/configs/ch_PP-OCRv3_det/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml -o +norm_train:tools/train.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml -o Global.print_batch_step=1 Train.loader.shuffle=false Global.eval_batch_step=[4000,400] pact_train:null fpgm_train:null distill_train:null @@ -51,3 +51,9 @@ null:null null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] +===========================train_benchmark_params========================== +batch_size:8 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml b/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml index f704a1dfb5dc2335c353a495dfbc0ce42cf35bf4..ee884f668767ea1c96782072c729bbcc700674d1 100644 --- a/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml +++ b/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml @@ -153,7 +153,7 @@ Train: data_dir: ./train_data/ic15_data/ ext_op_transform_idx: 1 label_file_list: - - ./train_data/ic15_data/rec_gt_train_lite.txt + - ./train_data/ic15_data/rec_gt_train4w.txt transforms: - DecodeImage: img_mode: BGR @@ -183,7 +183,7 @@ Eval: name: SimpleDataSet data_dir: ./train_data/ic15_data label_file_list: - - ./train_data/ic15_data/rec_gt_test_lite.txt + - ./train_data/ic15_data/rec_gt_test.txt transforms: - DecodeImage: img_mode: BGR diff --git a/test_tipc/configs/ch_PP-OCRv3_rec/train_infer_python.txt b/test_tipc/configs/ch_PP-OCRv3_rec/train_infer_python.txt index 1feb9d49fce69d92ef141c3a942f858fc68cfaab..420c6592d71653377c740c703bedeb8e048cfc03 100644 --- a/test_tipc/configs/ch_PP-OCRv3_rec/train_infer_python.txt +++ b/test_tipc/configs/ch_PP-OCRv3_rec/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./inference/rec_inference null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml -o +norm_train:tools/train.py -c test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml -o Global.print_batch_step=1 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -51,3 +51,9 @@ null:null null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,48,320]}] +===========================train_benchmark_params========================== +batch_size:128 +fp_items:fp32|fp16 +epoch:1 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/ch_ppocr_mobile_v2.0_det/train_infer_python.txt b/test_tipc/configs/ch_ppocr_mobile_v2.0_det/train_infer_python.txt index 789ed4d23d9c1fa3997daceee0627218aecd4c73..3db816cc0887eb2efc195965498174e868bfc6ec 100644 --- a/test_tipc/configs/ch_ppocr_mobile_v2.0_det/train_infer_python.txt +++ b/test_tipc/configs/ch_ppocr_mobile_v2.0_det/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained +norm_train:tools/train.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained Global.print_batch_step=1 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -50,4 +50,10 @@ null:null --benchmark:True null:null ===========================infer_benchmark_params========================== -random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] \ No newline at end of file +random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] +===========================train_benchmark_params========================== +batch_size:8 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/ch_ppocr_mobile_v2.0_rec/train_infer_python.txt b/test_tipc/configs/ch_ppocr_mobile_v2.0_rec/train_infer_python.txt index f02b93926cac8116844142fe3ecb03959abb0530..36fdb1b91eceede0d692ff4c2680d1403ec86024 100644 --- a/test_tipc/configs/ch_ppocr_mobile_v2.0_rec/train_infer_python.txt +++ b/test_tipc/configs/ch_ppocr_mobile_v2.0_rec/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./inference/rec_inference null:null ## trainer:norm_train -norm_train:tools/train.py -c configs/rec/rec_icdar15_train.yml -o +norm_train:tools/train.py -c configs/rec/rec_icdar15_train.yml -o Global.print_batch_step=4 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -51,3 +51,9 @@ inference:tools/infer/predict_rec.py null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,32,100]}] +===========================train_benchmark_params========================== +batch_size:256 +fp_items:fp32|fp16 +epoch:3 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/ch_ppocr_server_v2.0_det/det_r50_vd_db.yml b/test_tipc/configs/ch_ppocr_server_v2.0_det/det_r50_vd_db.yml index f512de808141a0a0e815f9477de80b893ae3c946..6728703a10c2eb4e19b3bbf2225f089324e7d5cd 100644 --- a/test_tipc/configs/ch_ppocr_server_v2.0_det/det_r50_vd_db.yml +++ b/test_tipc/configs/ch_ppocr_server_v2.0_det/det_r50_vd_db.yml @@ -2,13 +2,13 @@ Global: use_gpu: false epoch_num: 5 log_smooth_window: 20 - print_batch_step: 1 + print_batch_step: 2 save_model_dir: ./output/db_mv3/ save_epoch_step: 1200 # evaluation is run every 2000 iterations - eval_batch_step: [0, 400] + eval_batch_step: [0, 30000] cal_metric_during_train: False - pretrained_model: ./pretrain_models/MobileNetV3_large_x0_5_pretrained + pretrained_model: checkpoints: save_inference_dir: use_visualdl: False diff --git a/test_tipc/configs/ch_ppocr_server_v2.0_det/train_infer_python.txt b/test_tipc/configs/ch_ppocr_server_v2.0_det/train_infer_python.txt index c16ca150029d03052396ca28a6396520e63b3f84..7b90a4078a0c30f9d5ecab60c82acbd4052821ea 100644 --- a/test_tipc/configs/ch_ppocr_server_v2.0_det/train_infer_python.txt +++ b/test_tipc/configs/ch_ppocr_server_v2.0_det/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/ch_ppocr_server_v2.0_det/det_r50_vd_db.yml -o +norm_train:tools/train.py -c test_tipc/configs/ch_ppocr_server_v2.0_det/det_r50_vd_db.yml -o quant_train:null fpgm_train:null distill_train:null @@ -50,4 +50,10 @@ inference:tools/infer/predict_det.py --benchmark:True null:null ===========================infer_benchmark_params========================== -random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] \ No newline at end of file +random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] +===========================train_benchmark_params========================== +batch_size:8 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/ch_ppocr_server_v2.0_rec/train_infer_python.txt b/test_tipc/configs/ch_ppocr_server_v2.0_rec/train_infer_python.txt index 64c0cf455cdd058d1840a9ad1f86954293d2e219..9fc117d67c6c2c048b2c8797bc07be8c93b0d519 100644 --- a/test_tipc/configs/ch_ppocr_server_v2.0_rec/train_infer_python.txt +++ b/test_tipc/configs/ch_ppocr_server_v2.0_rec/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./inference/rec_inference null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/ch_ppocr_server_v2.0_rec/rec_icdar15_train.yml -o +norm_train:tools/train.py -c test_tipc/configs/ch_ppocr_server_v2.0_rec/rec_icdar15_train.yml -o Global.print_batch_step=4 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -51,3 +51,9 @@ inference:tools/infer/predict_rec.py null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,32,100]}] +===========================train_benchmark_params========================== +batch_size:256 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/det_mv3_db_v2_0/train_infer_python.txt b/test_tipc/configs/det_mv3_db_v2_0/train_infer_python.txt index 2c8aa953449c4b97790842bb90256280b8b20d9a..62303b7e511bc42444e3610fb17eaf74ccf0848a 100644 --- a/test_tipc/configs/det_mv3_db_v2_0/train_infer_python.txt +++ b/test_tipc/configs/det_mv3_db_v2_0/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained +norm_train:tools/train.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained Global.print_batch_step=1 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -52,8 +52,8 @@ null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] ===========================train_benchmark_params========================== -batch_size:8|16 +batch_size:16 fp_items:fp32|fp16 -epoch:15 +epoch:4 --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile -flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 \ No newline at end of file diff --git a/test_tipc/configs/det_r50_db_v2.0/train_infer_python.txt b/test_tipc/configs/det_r50_db_v2.0/train_infer_python.txt index 151f2769cc2d97d6a3546f338383dd811aa06ace..11af0ad18e948d9fa1f325745988877125583658 100644 --- a/test_tipc/configs/det_r50_db_v2.0/train_infer_python.txt +++ b/test_tipc/configs/det_r50_db_v2.0/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c configs/det/det_r50_vd_db.yml -o +norm_train:tools/train.py -c configs/det/det_r50_vd_db.yml -o Global.print_batch_step=1 Train.loader.shuffle=false quant_export:null fpgm_export:null distill_train:null @@ -50,4 +50,10 @@ inference:tools/infer/predict_det.py --benchmark:True null:null ===========================infer_benchmark_params========================== -random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] \ No newline at end of file +random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] +===========================train_benchmark_params========================== +batch_size:8 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 \ No newline at end of file diff --git a/test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/det_r50_vd_dcn_fce_ctw.yml b/test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/det_r50_vd_dcn_fce_ctw.yml new file mode 100644 index 0000000000000000000000000000000000000000..3a513b8f38cd5abf800c86f8fbeda789cb3d056a --- /dev/null +++ b/test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/det_r50_vd_dcn_fce_ctw.yml @@ -0,0 +1,139 @@ +Global: + use_gpu: true + epoch_num: 1500 + log_smooth_window: 20 + print_batch_step: 20 + save_model_dir: ./output/det_r50_dcn_fce_ctw/ + save_epoch_step: 100 + # evaluation is run every 835 iterations + eval_batch_step: [0, 4000] + cal_metric_during_train: False + pretrained_model: ./pretrain_models/ResNet50_vd_ssld_pretrained + checkpoints: + save_inference_dir: + use_visualdl: False + infer_img: doc/imgs_en/img_10.jpg + save_res_path: ./output/det_fce/predicts_fce.txt + + +Architecture: + model_type: det + algorithm: FCE + Transform: + Backbone: + name: ResNet_vd + layers: 50 + dcn_stage: [False, True, True, True] + out_indices: [1,2,3] + Neck: + name: FCEFPN + out_channels: 256 + has_extra_convs: False + extra_stage: 0 + Head: + name: FCEHead + fourier_degree: 5 +Loss: + name: FCELoss + fourier_degree: 5 + num_sample: 50 + +Optimizer: + name: Adam + beta1: 0.9 + beta2: 0.999 + lr: + learning_rate: 0.0001 + regularizer: + name: 'L2' + factor: 0 + +PostProcess: + name: FCEPostProcess + scales: [8, 16, 32] + alpha: 1.0 + beta: 1.0 + fourier_degree: 5 + box_type: 'poly' + +Metric: + name: DetFCEMetric + main_indicator: hmean + +Train: + dataset: + name: SimpleDataSet + data_dir: ./train_data/icdar2015/text_localization/ + label_file_list: + - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt + transforms: + - DecodeImage: # load image + img_mode: BGR + channel_first: False + ignore_orientation: True + - DetLabelEncode: # Class handling label + - ColorJitter: + brightness: 0.142 + saturation: 0.5 + contrast: 0.5 + - RandomScaling: + - RandomCropFlip: + crop_ratio: 0.5 + - RandomCropPolyInstances: + crop_ratio: 0.8 + min_side_ratio: 0.3 + - RandomRotatePolyInstances: + rotate_ratio: 0.5 + max_angle: 30 + pad_with_fixed_color: False + - SquareResizePad: + target_size: 800 + pad_ratio: 0.6 + - IaaAugment: + augmenter_args: + - { 'type': Fliplr, 'args': { 'p': 0.5 } } + - FCENetTargets: + fourier_degree: 5 + - NormalizeImage: + scale: 1./255. + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: 'hwc' + - ToCHWImage: + - KeepKeys: + keep_keys: ['image', 'p3_maps', 'p4_maps', 'p5_maps'] # dataloader will return list in this order + loader: + shuffle: True + drop_last: False + batch_size_per_card: 6 + num_workers: 8 + +Eval: + dataset: + name: SimpleDataSet + data_dir: ./train_data/icdar2015/text_localization/ + label_file_list: + - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt + transforms: + - DecodeImage: # load image + img_mode: BGR + channel_first: False + ignore_orientation: True + - DetLabelEncode: # Class handling label + - DetResizeForTest: + limit_type: 'min' + limit_side_len: 736 + - NormalizeImage: + scale: 1./255. + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: 'hwc' + - Pad: + - ToCHWImage: + - KeepKeys: + keep_keys: ['image', 'shape', 'polys', 'ignore_tags'] + loader: + shuffle: False + drop_last: False + batch_size_per_card: 1 # must be 1 + num_workers: 2 \ No newline at end of file diff --git a/test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/train_infer_python.txt b/test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/train_infer_python.txt new file mode 100644 index 0000000000000000000000000000000000000000..2d294fd3038f5506a28d637dbe1aba44b5da237b --- /dev/null +++ b/test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/train_infer_python.txt @@ -0,0 +1,59 @@ +===========================train_params=========================== +model_name:det_r50_dcn_fce_ctw_v2.0 +python:python3.7 +gpu_list:0 +Global.use_gpu:True|True +Global.auto_cast:fp32 +Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 +Global.save_model_dir:./output/ +Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 +Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ +null:null +## +trainer:norm_train +norm_train:tools/train.py -c test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/det_r50_vd_dcn_fce_ctw.yml -o Global.print_batch_step=1 Train.loader.shuffle=false +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:null +null:null +## +===========================infer_params=========================== +Global.save_inference_dir:./output/ +Global.checkpoints: +norm_export:tools/export_model.py -c test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/det_r50_vd_dcn_fce_ctw.yml -o +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +## +train_model:./inference/det_r50_dcn_fce_ctw_v2.0_train/best_accuracy +infer_export:tools/export_model.py -c test_tipc/configs/det_r50_dcn_fce_ctw_v2.0/det_r50_vd_dcn_fce_ctw.yml -o +infer_quant:False +inference:tools/infer/predict_det.py +--use_gpu:True|False +--enable_mkldnn:False +--cpu_threads:6 +--rec_batch_num:1 +--use_tensorrt:False +--precision:fp32 +--det_model_dir: +--image_dir:./inference/ch_det_data_50/all-sum-510/ +--save_log_path:null +--benchmark:True +--det_algorithm:FCE +===========================infer_benchmark_params========================== +random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] +===========================train_benchmark_params========================== +batch_size:6 +fp_items:fp32|fp16 +epoch:1 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 \ No newline at end of file diff --git a/test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml b/test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml index c6b6fc3ed79d0d717fe3dbd4cb9c8559ff8f07c4..844f42e9ad2b4eafbbd829de5711132f8119671f 100644 --- a/test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml +++ b/test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml @@ -20,7 +20,7 @@ Architecture: algorithm: EAST Transform: Backbone: - name: ResNet + name: ResNet_vd layers: 50 Neck: name: EASTFPN diff --git a/test_tipc/configs/det_r50_vd_east_v2_0/train_infer_python.txt b/test_tipc/configs/det_r50_vd_east_v2_0/train_infer_python.txt index 24e4d760c37828c213741b9ff127d55df2f9335a..5ee445a6cd03dfb888d1bc73eb51481a014cbb36 100644 --- a/test_tipc/configs/det_r50_vd_east_v2_0/train_infer_python.txt +++ b/test_tipc/configs/det_r50_vd_east_v2_0/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml -o +norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml -o Global.pretrained_model=pretrain_models/det_r50_vd_east_v2.0_train/best_accuracy.pdparams Global.print_batch_step=1 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -55,4 +55,5 @@ random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] batch_size:8 fp_items:fp32|fp16 epoch:2 ---profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile \ No newline at end of file +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 \ No newline at end of file diff --git a/test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml b/test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml index f7e60fd1968820ef093455473346a6b8f0f8d34e..c069d1f132db5fc512011ead0107cf4082c144be 100644 --- a/test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml +++ b/test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml @@ -8,7 +8,7 @@ Global: # evaluation is run every 125 iterations eval_batch_step: [ 0,1000 ] cal_metric_during_train: False - pretrained_model: + pretrained_model: ./pretrain_models/ResNet50_vd_ssld_pretrained checkpoints: #./output/det_r50_vd_pse_batch8_ColorJitter/best_accuracy save_inference_dir: use_visualdl: False @@ -20,7 +20,7 @@ Architecture: algorithm: PSE Transform: Backbone: - name: ResNet + name: ResNet_vd layers: 50 Neck: name: FPN diff --git a/test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt b/test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt index 53511e6ae21003cb9df6a92d3931577fbbef5b18..78d25f6b17e30d6b7b12ae3acc1b264febfa97da 100644 --- a/test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt +++ b/test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml -o +norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml -o Global.print_batch_step=1 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -54,5 +54,6 @@ random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}] ===========================train_benchmark_params========================== batch_size:8 fp_items:fp32|fp16 -epoch:10 +epoch:2 --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 \ No newline at end of file diff --git a/test_tipc/configs/en_table_structure/table_mv3.yml b/test_tipc/configs/en_table_structure/table_mv3.yml index 281038b968a5bf829483882117d779ec7de1976d..5d8e84c95c477a639130a342c6c72345e97701da 100755 --- a/test_tipc/configs/en_table_structure/table_mv3.yml +++ b/test_tipc/configs/en_table_structure/table_mv3.yml @@ -6,7 +6,7 @@ Global: save_model_dir: ./output/table_mv3/ save_epoch_step: 3 # evaluation is run every 400 iterations after the 0th iteration - eval_batch_step: [0, 400] + eval_batch_step: [0, 40000] cal_metric_during_train: True pretrained_model: checkpoints: diff --git a/test_tipc/configs/en_table_structure/train_infer_python.txt b/test_tipc/configs/en_table_structure/train_infer_python.txt index d9f3b30e16c75281a929130d877b947a23c16190..633b6185d976ac61408283025bd4ba305187317d 100644 --- a/test_tipc/configs/en_table_structure/train_infer_python.txt +++ b/test_tipc/configs/en_table_structure/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./ppstructure/docs/table/table.jpg null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/en_table_structure/table_mv3.yml -o +norm_train:tools/train.py -c test_tipc/configs/en_table_structure/table_mv3.yml -o Global.print_batch_step=1 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -27,7 +27,7 @@ null:null ===========================infer_params=========================== Global.save_inference_dir:./output/ Global.checkpoints: -norm_export:tools/export_model.py -c test_tipc/configs/en_table_structure/table_mv3.yml -o +norm_export:tools/export_model.py -c test_tipc/configs/en_table_structure/table_mv3.yml -o quant_export: fpgm_export: distill_export:null @@ -51,3 +51,9 @@ null:null null:null ===========================infer_benchmark_params========================== random_infer_input:[{float32,[3,488,488]}] +===========================train_benchmark_params========================== +batch_size:32 +fp_items:fp32|fp16 +epoch:1 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/rec_icdar15_train.yml b/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/rec_icdar15_train.yml index 463e8d1d7d7f43ba7b48810e2a2e8552eb5e4fe3..b0ba615293153cc3bbeb5b47d053596306ee45e2 100644 --- a/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/rec_icdar15_train.yml +++ b/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/rec_icdar15_train.yml @@ -6,7 +6,7 @@ Global: save_model_dir: ./output/rec/mv3_none_bilstm_ctc/ save_epoch_step: 3 # evaluation is run every 2000 iterations - eval_batch_step: [0, 2000] + eval_batch_step: [0, 20000] cal_metric_during_train: True pretrained_model: checkpoints: diff --git a/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/train_infer_python.txt b/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/train_infer_python.txt index 39bf9227902480ffe4ed37d454c21d6a163c41bd..4e34a6a525fb8104407d04c617db39934b84e140 100644 --- a/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/train_infer_python.txt +++ b/test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/train_infer_python.txt @@ -13,7 +13,7 @@ train_infer_img_dir:./inference/rec_inference null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/rec_icdar15_train.yml -o +norm_train:tools/train.py -c test_tipc/configs/rec_mv3_none_bilstm_ctc_v2.0/rec_icdar15_train.yml -o Global.print_batch_step=4 Train.loader.shuffle=false pact_train:null fpgm_train:null distill_train:null @@ -50,4 +50,10 @@ inference:tools/infer/predict_rec.py --rec_char_dict_path=./ppocr/utils/ic15_dic --benchmark:True null:null ===========================infer_benchmark_params========================== -random_infer_input:[{float32,[3,32,100]}] \ No newline at end of file +random_infer_input:[{float32,[3,32,100]}] +===========================train_benchmark_params========================== +batch_size:256 +fp_items:fp32|fp16 +epoch:4 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile +flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 diff --git a/test_tipc/docs/benchmark_train.md b/test_tipc/docs/benchmark_train.md index ad2524c165da3079d24b2b1570a5111d152f8373..a7f95eb6c530e1c451bb400cdb193694e2aee5f6 100644 --- a/test_tipc/docs/benchmark_train.md +++ b/test_tipc/docs/benchmark_train.md @@ -51,3 +51,25 @@ train_log/ ├── PaddleOCR_det_mv3_db_v2_0_bs8_fp32_SingleP_DP_N1C1_log └── PaddleOCR_det_mv3_db_v2_0_bs8_fp32_SingleP_DP_N1C4_log ``` +## 3. 各模型单卡性能数据一览 + +*注:本节中的速度指标均使用单卡(1块Nvidia V100 16G GPU)测得。通常情况下。 + + +|模型名称|配置文件|大数据集 float32 fps |小数据集 float32 fps |diff |大数据集 float16 fps|小数据集 float16 fps| diff | 大数据集大小 | 小数据集大小 | +|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +| ch_ppocr_mobile_v2.0_det |[config](../configs/ch_ppocr_mobile_v2.0_det/train_infer_python.txt) | 53.836 | 53.343 / 53.914 / 52.785 |0.020940758 | 45.574 | 45.57 / 46.292 / 46.213 | 0.015596647 | 10,000| 2,000| +| ch_ppocr_mobile_v2.0_rec |[config](../configs/ch_ppocr_mobile_v2.0_rec/train_infer_python.txt) | 2083.311 | 2043.194 / 2066.372 / 2093.317 |0.023944295 | 2153.261 | 2167.561 / 2165.726 / 2155.614| 0.005511725 | 600,000| 160,000| +| ch_ppocr_server_v2.0_det |[config](../configs/ch_ppocr_server_v2.0_det/train_infer_python.txt) | 20.716 | 20.739 / 20.807 / 20.755 |0.003268131 | 20.592 | 20.498 / 20.993 / 20.75| 0.023579288 | 10,000| 2,000| +| ch_ppocr_server_v2.0_rec |[config](../configs/ch_ppocr_server_v2.0_rec/train_infer_python.txt) | 528.56 | 528.386 / 528.991 / 528.391 |0.001143687 | 1189.788 | 1190.007 / 1176.332 / 1192.084| 0.013213834 | 600,000| 160,000| +| ch_PP-OCRv2_det |[config](../configs/ch_PP-OCRv2_det/train_infer_python.txt) | 13.87 | 13.386 / 13.529 / 13.428 |0.010569887 | 17.847 | 17.746 / 17.908 / 17.96| 0.011915367 | 10,000| 2,000| +| ch_PP-OCRv2_rec |[config](../configs/ch_PP-OCRv2_rec/train_infer_python.txt) | 109.248 | 106.32 / 106.318 / 108.587 |0.020895687 | 117.491 | 117.62 / 117.757 / 117.726| 0.001163413 | 140,000| 40,000| +| det_mv3_db_v2.0 |[config](../configs/det_mv3_db_v2_0/train_infer_python.txt) | 61.802 | 62.078 / 61.802 / 62.008 |0.00444602 | 82.947 | 84.294 / 84.457 / 84.005| 0.005351836 | 10,000| 2,000| +| det_r50_vd_db_v2.0 |[config](../configs/det_r50_vd_db_v2.0/train_infer_python.txt) | 29.955 | 29.092 / 29.31 / 28.844 |0.015899011 | 51.097 |50.367 / 50.879 / 50.227| 0.012814717 | 10,000| 2,000| +| det_r50_vd_east_v2.0 |[config](../configs/det_r50_vd_east_v2.0/train_infer_python.txt) | 42.485 | 42.624 / 42.663 / 42.561 |0.00239083 | 67.61 |67.825/ 68.299/ 68.51| 0.00999854 | 10,000| 2,000| +| det_r50_vd_pse_v2.0 |[config](../configs/det_r50_vd_pse_v2.0/train_infer_python.txt) | 16.455 | 16.517 / 16.555 / 16.353 |0.012201752 | 27.02 |27.288 / 27.152 / 27.408| 0.009340339 | 10,000| 2,000| +| rec_mv3_none_bilstm_ctc_v2.0 |[config](../configs/rec_mv3_none_bilstm_ctc_v2.0/train_infer_python.txt) | 2288.358 | 2291.906 / 2293.725 / 2290.05 |0.001602197 | 2336.17 |2327.042 / 2328.093 / 2344.915| 0.007622025 | 600,000| 160,000| +| PP-Structure-table |[config](../configs/en_table_structure/train_infer_python.txt) | 14.151 | 14.077 / 14.23 / 14.25 |0.012140351 | 16.285 | 16.595 / 16.878 / 16.531 | 0.020559308 | 20,000| 5,000| +| det_r50_dcn_fce_ctw_v2.0 |[config](../configs/det_r50_dcn_fce_ctw_v2.0/train_infer_python.txt) | 14.057 | 14.029 / 14.02 / 14.014 |0.001069214 | 18.298 |18.411 / 18.376 / 18.331| 0.004345228 | 10,000| 2,000| +| ch_PP-OCRv3_det |[config](../configs/ch_PP-OCRv3_det/train_infer_python.txt) | 8.622 | 8.431 / 8.423 / 8.479|0.006604552 | 14.203 |14.346 14.468 14.23| 0.016450097 | 10,000| 2,000| +| ch_PP-OCRv3_rec |[config](../configs/ch_PP-OCRv3_rec/train_infer_python.txt) | 73.627 | 72.46 / 73.575 / 73.704|0.016878324 | | | | 160,000| 40,000| \ No newline at end of file diff --git a/test_tipc/prepare.sh b/test_tipc/prepare.sh index ec6dece42a0126e6d05405b3262c1c1d24f0a376..cb3fa2440d9672ba113904bd1548d458491d1d8c 100644 --- a/test_tipc/prepare.sh +++ b/test_tipc/prepare.sh @@ -22,27 +22,79 @@ trainer_list=$(func_parser_value "${lines[14]}") if [ ${MODE} = "benchmark_train" ];then pip install -r requirements.txt - if [[ ${model_name} =~ "det_mv3_db_v2_0" || ${model_name} =~ "det_r50_vd_pse_v2_0" || ${model_name} =~ "det_r18_db_v2_0" ]];then - rm -rf ./train_data/icdar2015 + if [[ ${model_name} =~ "ch_ppocr_mobile_v2.0_det" || ${model_name} =~ "det_mv3_db_v2_0" ]];then wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/pretrained/MobileNetV3_large_x0_5_pretrained.pdparams --no-check-certificate - wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar --no-check-certificate - cd ./train_data/ && tar xf icdar2015.tar && cd ../ + rm -rf ./train_data/icdar2015 + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/icdar2015_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf icdar2015_benckmark.tar + ln -s ./icdar2015_benckmark ./icdar2015 + cd ../ + fi + if [[ ${model_name} =~ "ch_ppocr_server_v2.0_det" || ${model_name} =~ "ch_PP-OCRv3_det" ]];then + rm -rf ./train_data/icdar2015 + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/icdar2015_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf icdar2015_benckmark.tar + ln -s ./icdar2015_benckmark ./icdar2015 + cd ../ + fi + if [[ ${model_name} =~ "ch_PP-OCRv2_det" ]];then + wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_train.tar --no-check-certificate + cd ./pretrain_models/ && tar xf ch_ppocr_server_v2.0_det_train.tar && cd ../ + rm -rf ./train_data/icdar2015 + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/icdar2015_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf icdar2015_benckmark.tar + ln -s ./icdar2015_benckmark ./icdar2015 + cd ../ fi if [[ ${model_name} =~ "det_r50_vd_east_v2_0" ]]; then wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar --no-check-certificate cd ./pretrain_models/ && tar xf det_r50_vd_east_v2.0_train.tar && cd ../ - wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar --no-check-certificate - cd ./train_data/ && tar xf icdar2015.tar && cd ../ + rm -rf ./train_data/icdar2015 + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/icdar2015_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf icdar2015_benckmark.tar + ln -s ./icdar2015_benckmark ./icdar2015 + cd ../ fi - if [[ ${model_name} =~ "det_r50_vd_pse_v2_0" ]];then + if [[ ${model_name} =~ "det_r50_db_v2.0" || ${model_name} =~ "det_r50_vd_pse_v2_0" ]];then wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/pretrained/ResNet50_vd_ssld_pretrained.pdparams --no-check-certificate - wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar --no-check-certificate - cd ./train_data/ && tar xf icdar2015.tar && cd ../ + rm -rf ./train_data/icdar2015 + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/icdar2015_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf icdar2015_benckmark.tar + ln -s ./icdar2015_benckmark ./icdar2015 + cd ../ fi if [[ ${model_name} =~ "det_r18_db_v2_0" ]];then wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/pretrained/ResNet18_vd_pretrained.pdparams --no-check-certificate - wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar --no-check-certificate - cd ./train_data/ && tar xf icdar2015.tar && cd ../ + rm -rf ./train_data/icdar2015 + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/icdar2015_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf icdar2015_benckmark.tar + ln -s ./icdar2015_benckmark ./icdar2015 + cd ../ + fi + if [[ ${model_name} =~ "ch_ppocr_mobile_v2.0_rec" || ${model_name} =~ "ch_ppocr_server_v2.0_rec" || ${model_name} =~ "ch_PP-OCRv2_rec" || ${model_name} =~ "rec_mv3_none_bilstm_ctc_v2.0" || ${model_name} =~ "ch_PP-OCRv3_rec" ]];then + rm -rf ./train_data/ic15_data_benckmark + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/ic15_data_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf ic15_data_benckmark.tar + ln -s ./ic15_data_benckmark ./ic15_data + cd ../ + fi + if [[ ${model_name} == "en_table_structure" ]];then + wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_structure_train.tar --no-check-certificate + cd ./pretrain_models/ && tar xf en_ppocr_mobile_v2.0_table_structure_train.tar && cd ../ + rm -rf ./train_data/pubtabnet + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/pubtabnet_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf pubtabnet_benckmark.tar + ln -s ./pubtabnet_benckmark ./pubtabnet + cd ../ + fi + if [[ ${model_name} == "det_r50_dcn_fce_ctw_v2.0" ]]; then + wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/contribution/det_r50_dcn_fce_ctw_v2.0_train.tar --no-check-certificate + cd ./pretrain_models/ && tar xf det_r50_dcn_fce_ctw_v2.0_train.tar && cd ../ + rm -rf ./train_data/icdar2015 + wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/icdar2015_benckmark.tar --no-check-certificate + cd ./train_data/ && tar xf icdar2015_benckmark.tar + ln -s ./icdar2015_benckmark ./icdar2015 + cd ../ fi fi @@ -137,6 +189,10 @@ if [ ${MODE} = "lite_train_lite_infer" ];then wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar --no-check-certificate cd ./pretrain_models/ && tar xf det_r50_vd_east_v2.0_train.tar && cd ../ fi + if [ ${model_name} == "det_r50_dcn_fce_ctw_v2.0" ]; then + wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/contribution/det_r50_dcn_fce_ctw_v2.0_train.tar --no-check-certificate + cd ./pretrain_models/ && tar xf det_r50_dcn_fce_ctw_v2.0_train.tar & cd ../ + fi elif [ ${MODE} = "whole_train_whole_infer" ];then wget -nc -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams --no-check-certificate @@ -363,6 +419,10 @@ elif [ ${MODE} = "whole_infer" ];then wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar --no-check-certificate cd ./inference/ && tar xf det_r50_vd_east_v2.0_train.tar & cd ../ fi + if [ ${model_name} == "det_r50_dcn_fce_ctw_v2.0" ]; then + wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/contribution/det_r50_dcn_fce_ctw_v2.0_train.tar --no-check-certificate + cd ./inference/ && tar xf det_r50_dcn_fce_ctw_v2.0_train.tar & cd ../ + fi if [[ ${model_name} =~ "en_table_structure" ]];then wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar --no-check-certificate wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar --no-check-certificate diff --git a/test_tipc/readme.md b/test_tipc/readme.md index 1c637d76f99fffdfdc5a053fa0c5b9336fe4b731..f9e9d89e4198c1ad5fabdf58775c6f7b6d190322 100644 --- a/test_tipc/readme.md +++ b/test_tipc/readme.md @@ -53,6 +53,7 @@ | SRN |rec_r50fpn_vd_none_srn | 识别 | 支持 | 多机多卡
混合精度 | - | - | | NRTR |rec_mtb_nrtr | 识别 | 支持 | 多机多卡
混合精度 | - | - | | SAR |rec_r31_sar | 识别 | 支持 | 多机多卡
混合精度 | - | - | +| SPIN |rec_r32_gaspin_bilstm_att | 识别 | 支持 | 多机多卡
混合精度 | - | - | | PGNet |rec_r34_vd_none_none_ctc_v2.0 | 端到端| 支持 | 多机多卡
混合精度 | - | - | | TableMaster |table_structure_tablemaster_train | 表格识别| 支持 | 多机多卡
混合精度 | - | - | diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py index e1d0d596ea82deeca3665a9eafd2fa78d6863a19..4e4150c515fc2d0ee4eb7e635cb8c81a467e748f 100755 --- a/tools/infer/predict_rec.py +++ b/tools/infer/predict_rec.py @@ -89,7 +89,7 @@ class TextRecognizer(object): } elif self.rec_algorithm == "SPIN": postprocess_params = { - 'name': 'SPINAttnLabelDecode', + 'name': 'SPINLabelDecode', "character_dict_path": args.rec_char_dict_path, "use_space_char": args.use_space_char } diff --git a/tools/program.py b/tools/program.py index 404b9164d4d00954c0382122465d3bcb8362eeae..b2052b116d2e5de79b59f5a30b6eed7ec859ccee 100755 --- a/tools/program.py +++ b/tools/program.py @@ -155,6 +155,26 @@ def check_xpu(use_xpu): pass +def to_float32(preds): + if isinstance(preds, dict): + for k in preds: + if isinstance(preds[k], dict) or isinstance(preds[k], list): + preds[k] = to_float32(preds[k]) + else: + preds[k] = preds[k].astype(paddle.float32) + elif isinstance(preds, list): + for k in range(len(preds)): + if isinstance(preds[k], dict): + preds[k] = to_float32(preds[k]) + elif isinstance(preds[k], list): + preds[k] = to_float32(preds[k]) + else: + preds[k] = preds[k].astype(paddle.float32) + else: + preds = preds.astype(paddle.float32) + return preds + + def train(config, train_dataloader, valid_dataloader, @@ -253,13 +273,19 @@ def train(config, model_average = True # use amp if scaler: - with paddle.amp.auto_cast(): + with paddle.amp.auto_cast(level='O2'): if model_type == 'table' or extra_input: preds = model(images, data=batch[1:]) elif model_type in ["kie", 'vqa']: preds = model(batch) else: preds = model(images) + preds = to_float32(preds) + loss = loss_class(preds, batch) + avg_loss = loss['loss'] + scaled_avg_loss = scaler.scale(avg_loss) + scaled_avg_loss.backward() + scaler.minimize(optimizer, scaled_avg_loss) else: if model_type == 'table' or extra_input: preds = model(images, data=batch[1:]) @@ -267,14 +293,8 @@ def train(config, preds = model(batch) else: preds = model(images) - loss = loss_class(preds, batch) - avg_loss = loss['loss'] - - if scaler: - scaled_avg_loss = scaler.scale(avg_loss) - scaled_avg_loss.backward() - scaler.minimize(optimizer, scaled_avg_loss) - else: + loss = loss_class(preds, batch) + avg_loss = loss['loss'] avg_loss.backward() optimizer.step() optimizer.clear_grad() diff --git a/tools/train.py b/tools/train.py index b7c25e34231fb650fd2c7c89dc17320f561962f9..309d4bb9e6b0fbcc9dd93545877662d746ada086 100755 --- a/tools/train.py +++ b/tools/train.py @@ -157,6 +157,7 @@ def main(config, device, logger, vdl_writer): scaler = paddle.amp.GradScaler( init_loss_scaling=scale_loss, use_dynamic_loss_scaling=use_dynamic_loss_scaling) + model, optimizer = paddle.amp.decorate(models=model, optimizers=optimizer, level='O2', master_weight=True) else: scaler = None