Skip to content

Commit 6c26e88

Browse files
authored
[Doc] update SAR status (#1789)
* update SAR status and fix torchscript export * add reminder for SAR
1 parent 58bcdae commit 6c26e88

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

docs/en/04-supported-codebases/mmocr.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ Besides python API, mmdeploy SDK also provides other FFI (Foreign Function Inter
251251

252252
- ABINet for TensorRT require pytorch1.10+ and TensorRT 8.4+.
253253

254+
- SAR uses `valid_ratio` inside network inference, which causes performance drops. When the `valid_ratio`s between
255+
testing image and the image for conversion are quite different, the gap would be enlarged.
256+
254257
- For TensorRT backend, users have to choose the right config. For example, CRNN only accepts 1 channel input. Here is a recommendation table:
255258

256259
| Model | Config |

docs/zh_cn/04-supported-codebases/mmocr.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ print(texts)
255255

256256
- ABINet 在 TensorRT 后端要求使用 pytorch1.10+, TensorRT 8.4+。
257257

258+
- SAR 在网络推广中使用 `valid_ratio`,这会让导出的 ONNX 文件精度下降。当测试图片的 `valid_ratio`s 和转换图片的值差异很大,这种下降就会越多。
259+
258260
- 对于 TensorRT 后端,用户需要使用正确的配置文件。比如 CRNN 只接受单通道输入。下面是一个示例表格:
259261

260262
| Model | Config |

mmdeploy/codebase/mmocr/models/text_recognition/sar_decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def parallel_sar_decoder__2d_attention(
5252
attn_mask = torch.zeros(bsz, T, h, w + 1, c).to(attn_weight.device)
5353
for i, valid_ratio in enumerate(valid_ratios):
5454
# use torch.ceil to replace original math.ceil and if else in mmocr
55-
valid_width = torch.ceil(w * valid_ratio).long()
55+
valid_width = torch.tensor(w * valid_ratio).ceil().long()
5656
# use narrow to replace original [valid_width:] in mmocr
5757
attn_mask[i].narrow(2, valid_width, w + 1 - valid_width)[:] = 1
5858
attn_mask = attn_mask[:, :, :, :w, :]
@@ -123,7 +123,7 @@ def sequential_sar_decoder__2d_attention(self,
123123
attn_mask = torch.zeros(bsz, c, h, w + 1).to(attn_weight.device)
124124
for i, valid_ratio in enumerate(valid_ratios):
125125
# use torch.ceil to replace original math.ceil and if else in mmocr
126-
valid_width = torch.ceil(w * valid_ratio).long()
126+
valid_width = torch.tensor(w * valid_ratio).ceil().long()
127127
# use narrow to replace original [valid_width:] in mmocr
128128
attn_mask[i].narrow(2, valid_width, w + 1 - valid_width)[:] = 1
129129
attn_mask = attn_mask[:, :, :, :w]

mmdeploy/codebase/mmocr/models/text_recognition/sar_encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def sar_encoder__forward(
5454
T = holistic_feat.size(1)
5555
for i, valid_ratio in enumerate(valid_ratios):
5656
# use torch.ceil to replace original math.ceil and if else in mmocr
57-
valid_step = torch.ceil(T * valid_ratio).long() - 1
57+
valid_step = torch.tensor(T * valid_ratio).ceil().long() - 1
5858
valid_hf.append(holistic_feat[i, valid_step, :])
5959
valid_hf = torch.stack(valid_hf, dim=0)
6060
else:

tests/regression/mmocr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ models:
307307
pipelines:
308308
- *pipeline_ts_recognition_fp32
309309
- *pipeline_ort_recognition_dynamic_fp32
310-
- *pipeline_trt_recognition_dynamic_fp32_H48_C3
311310

312311
- name: SATRN
313312
metafile: configs/textrecog/satrn/metafile.yml

0 commit comments

Comments
 (0)