-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support more MMOCR models: DBNet++, TextSnake, ABINet, MRCNN (
#1534) * WIP ocr * add mrcnn rewrite * add any rewrite for abinet * export abinet to onnx * fix abinet onnx export * support abinet to tensorrt static and modify mmocr.yml * add textsnake and dbnetpp * support mrcnn in ORT and TRT * add a condition before update data_preprocessor scope * update doc and mmocr.yml * add ut * markdown and simple config * write build_pytorch_model in child class * update any_default * remove where in abi_language_decoder___get_length__default * keep where * fix UT * fix UT * fix UT * update mmocr.yml and config description * tensorrt-fp32 -> tensorrt * update doc
- Loading branch information
Showing
40 changed files
with
1,246 additions
and
67 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
configs/mmocr/text-detection/text-detection_mrcnn_onnxruntime_dynamic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
_base_ = ['./text-detection_static.py', '../../_base_/backends/onnxruntime.py'] | ||
onnx_config = dict( | ||
output_names=['dets', 'labels', 'masks'], | ||
dynamic_axes=dict( | ||
input=dict({ | ||
0: 'batch', | ||
2: 'height', | ||
3: 'width' | ||
}), | ||
dets=dict({ | ||
0: 'batch', | ||
1: 'num_dets' | ||
}), | ||
labels=dict({ | ||
0: 'batch', | ||
1: 'num_dets' | ||
}), | ||
masks=dict({ | ||
0: 'batch', | ||
1: 'num_dets', | ||
2: 'height', | ||
3: 'width' | ||
}))) | ||
codebase_config = dict( | ||
post_processing=dict( | ||
score_threshold=0.05, | ||
confidence_threshold=0.005, | ||
iou_threshold=0.5, | ||
max_output_boxes_per_class=200, | ||
pre_top_k=5000, | ||
keep_top_k=100, | ||
background_label_id=-1, | ||
export_postprocess_mask=False)) |
2 changes: 2 additions & 0 deletions
2
configs/mmocr/text-detection/text-detection_mrcnn_tensorrt-fp16_dynamic-320x320-2240x2240.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_base_ = ['./text-detection_mrcnn_tensorrt_dynamic-320x320-2240x2240.py'] | ||
backend_config = dict(common_config=dict(fp16_mode=True)) |
5 changes: 5 additions & 0 deletions
5
configs/mmocr/text-detection/text-detection_mrcnn_tensorrt-int8_dynamic-320x320-2240x2240.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
_base_ = ['./text-detection_mrcnn_tensorrt_dynamic-320x320-2240x2240.py'] | ||
|
||
backend_config = dict(common_config=dict(fp16_mode=True, int8_mode=True)) | ||
|
||
calib_config = dict(create_calib=True, calib_file='calib_data.h5') |
45 changes: 45 additions & 0 deletions
45
configs/mmocr/text-detection/text-detection_mrcnn_tensorrt_dynamic-320x320-2240x2240.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
_base_ = ['./text-detection_static.py', '../../_base_/backends/tensorrt.py'] | ||
onnx_config = dict( | ||
output_names=['dets', 'labels', 'masks'], | ||
dynamic_axes=dict( | ||
input=dict({ | ||
0: 'batch', | ||
2: 'height', | ||
3: 'width' | ||
}), | ||
dets=dict({ | ||
0: 'batch', | ||
1: 'num_dets' | ||
}), | ||
labels=dict({ | ||
0: 'batch', | ||
1: 'num_dets' | ||
}), | ||
masks=dict({ | ||
0: 'batch', | ||
1: 'num_dets', | ||
2: 'height', | ||
3: 'width' | ||
}))) | ||
|
||
backend_config = dict( | ||
common_config=dict(max_workspace_size=1 << 30), | ||
model_inputs=[ | ||
dict( | ||
input_shapes=dict( | ||
input=dict( | ||
min_shape=[1, 3, 320, 320], | ||
opt_shape=[1, 3, 600, 800], | ||
max_shape=[1, 3, 2240, 2240]))) | ||
]) | ||
|
||
codebase_config = dict( | ||
post_processing=dict( | ||
score_threshold=0.05, | ||
confidence_threshold=0.005, | ||
iou_threshold=0.5, | ||
max_output_boxes_per_class=200, | ||
pre_top_k=5000, | ||
keep_top_k=100, | ||
background_label_id=-1, | ||
export_postprocess_mask=False)) |
18 changes: 18 additions & 0 deletions
18
configs/mmocr/text-detection/text-detection_mrcnn_torchscript.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
_base_ = [ | ||
'../../_base_/torchscript_config.py', | ||
'../../_base_/backends/torchscript.py' | ||
] | ||
|
||
ir_config = dict(input_shape=None, output_names=['dets', 'labels', 'masks']) | ||
codebase_config = dict( | ||
type='mmocr', | ||
task='TextDetection', | ||
post_processing=dict( | ||
score_threshold=0.05, | ||
confidence_threshold=0.005, | ||
iou_threshold=0.5, | ||
max_output_boxes_per_class=200, | ||
pre_top_k=5000, | ||
keep_top_k=100, | ||
background_label_id=-1, | ||
export_postprocess_mask=False)) |
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt-fp16_dynamic-1x32x32-1x32x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt-fp16_dynamic-32x32-32x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
configs/mmocr/text-recognition/text-recognition_tensorrt-fp16_dynamic-48x64-48x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 3 channel and 48 height for SAR models | ||
_base_ = [ | ||
'./text-recognition_dynamic.py', '../../_base_/backends/tensorrt-fp16.py' | ||
] | ||
backend_config = dict( | ||
common_config=dict(max_workspace_size=1 << 30), | ||
model_inputs=[ | ||
dict( | ||
input_shapes=dict( | ||
input=dict( | ||
min_shape=[1, 3, 48, 64], | ||
opt_shape=[1, 3, 48, 64], | ||
max_shape=[1, 3, 48, 640]))) | ||
]) |
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt-fp16_static-1x32x32.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
configs/mmocr/text-recognition/text-recognition_tensorrt-fp16_static-32x128.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ABINet models use static input 32x128 | ||
_base_ = [ | ||
'./text-recognition_static.py', '../../_base_/backends/tensorrt-fp16.py' | ||
] | ||
|
||
onnx_config = dict(input_shape=[128, 32]) | ||
backend_config = dict( | ||
common_config=dict(max_workspace_size=1 << 30), | ||
model_inputs=[ | ||
dict( | ||
input_shapes=dict( | ||
input=dict( | ||
min_shape=[1, 3, 32, 128], | ||
opt_shape=[1, 3, 32, 128], | ||
max_shape=[1, 3, 32, 128]))) | ||
]) |
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt-int8_dynamic-1x32x32-1x32x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt-int8_dynamic-32x32-32x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
configs/mmocr/text-recognition/text-recognition_tensorrt-int8_dynamic-48x64-48x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 3 channel and 48 height for SAR models | ||
_base_ = [ | ||
'./text-recognition_dynamic.py', '../../_base_/backends/tensorrt-int8.py' | ||
] | ||
backend_config = dict( | ||
common_config=dict(max_workspace_size=1 << 30), | ||
model_inputs=[ | ||
dict( | ||
input_shapes=dict( | ||
input=dict( | ||
min_shape=[1, 3, 48, 64], | ||
opt_shape=[1, 3, 48, 64], | ||
max_shape=[1, 3, 48, 640]))) | ||
]) |
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt-int8_static-1x32x32.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
configs/mmocr/text-recognition/text-recognition_tensorrt-int8_static-32x128.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ABINet models use static input 32x128 | ||
_base_ = [ | ||
'./text-recognition_static.py', '../../_base_/backends/tensorrt-int8.py' | ||
] | ||
|
||
onnx_config = dict(input_shape=[128, 32]) | ||
backend_config = dict( | ||
common_config=dict(max_workspace_size=1 << 30), | ||
model_inputs=[ | ||
dict( | ||
input_shapes=dict( | ||
input=dict( | ||
min_shape=[1, 3, 32, 128], | ||
opt_shape=[1, 3, 32, 128], | ||
max_shape=[1, 3, 32, 128]))) | ||
]) |
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt_dynamic-1x32x32-1x32x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt_dynamic-32x32-32x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
configs/mmocr/text-recognition/text-recognition_tensorrt_dynamic-48x64-48x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 3 channel and 48 height for SAR models | ||
_base_ = ['./text-recognition_dynamic.py', '../../_base_/backends/tensorrt.py'] | ||
backend_config = dict( | ||
common_config=dict(max_workspace_size=1 << 30), | ||
model_inputs=[ | ||
dict( | ||
input_shapes=dict( | ||
input=dict( | ||
min_shape=[1, 3, 48, 64], | ||
opt_shape=[1, 3, 48, 64], | ||
max_shape=[1, 3, 48, 640]))) | ||
]) |
1 change: 1 addition & 0 deletions
1
configs/mmocr/text-recognition/text-recognition_tensorrt_static-1x32x32.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
configs/mmocr/text-recognition/text-recognition_tensorrt_static-32x128.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ABINet models use static input 32x128 | ||
_base_ = ['./text-recognition_static.py', '../../_base_/backends/tensorrt.py'] | ||
|
||
onnx_config = dict(input_shape=[128, 32]) | ||
backend_config = dict( | ||
common_config=dict(max_workspace_size=1 << 30), | ||
model_inputs=[ | ||
dict( | ||
input_shapes=dict( | ||
input=dict( | ||
min_shape=[1, 3, 32, 128], | ||
opt_shape=[1, 3, 32, 128], | ||
max_shape=[1, 3, 32, 128]))) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.