Repository: open-mmlab/mmocr

Issue:
Testing with a  KIE Model in in the MMOCR_Tutorial.ipynb
Thanks for your error report and we appreciate it a lot.

**Checklist**

1. I have searched related issues but cannot get the expected help.
2. The bug has not been fixed in the latest version.

**Describe the bug**
I have already installed the relative environments by the install.md
I want to test the KIE model, and find the demo code in the MMOCR_Tutorial.ipynb
When I run the test code, I met the following bug.

**Reproduction**


1. What command or script did you run?

```none
mkdir data
wget https://download.openmmlab.com/mmocr/data/wildreceipt.tar
tar -xf wildreceipt.tar 
mv wildreceipt ./data

python tools/test.py configs/kie/sdmgr/sdmgr_unet16_60e_wildreceipt.py https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt_20210405-16a47642.pth --eval macro_f1
```

2. Did you make any modifications on the code or config? Did you understand what you have modified?
no
3. What dataset did you use?
 wildreceipt dataset.
*A clear and concise description of what the bug is.such as
    -environment
![image](https://user-images.githubusercontent.com/44767932/128685547-fc6209ce-8650-4134-b31d-2c6b48ad18f5.png)


-Error traceback
![image](https://user-images.githubusercontent.com/44767932/128685619-f03be4f2-1e5d-4a2c-9564-dcadee9c0ecb.png)





Discussion:
This is an already known bug caused by MMDetection (https://github.com/open-mmlab/mmdetection/pull/5363), you can upgrade it to 2.14.0 and MMOCR to the latest one to avoid this issue.
> This is an already known bug caused by MMDetection ([open-mmlab/mmdetection#5363](https://github.com/open-mmlab/mmdetection/pull/5363)), you can upgrade it to 2.14.0 and MMOCR to the latest one to avoid this issue.

I updated as you said but still get errors.
![image](https://user-images.githubusercontent.com/44767932/128798286-8fa5b248-9739-4dd7-af94-8f67dacc4482.png)
My current version configuration is as follows
sys.platform: linux
Python: 3.7.11 (default, Jul 27 2021, 14:32:16) [GCC 7.5.0]
CUDA available: True
GPU 0,1: Tesla K80
CUDA_HOME: /usr/local/cuda-10.1
NVCC: Cuda compilation tools, release 10.1, V10.1.243
GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
PyTorch: 1.6.0
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) oneAPI Math Kernel Library Version 2021.3-Product Build 20210617 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v1.5.0 (Git Hash e2ac1fac44c5078ca927cb9b90e1b3066a0b2ed0)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 10.1
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_37,code=compute_37
  - CuDNN 7.6.3
  - Magma 2.5.2
  - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF, 

TorchVision: 0.7.0
OpenCV: 4.5.3
MMCV: 1.3.8
MMCV Compiler: GCC 7.3
MMCV CUDA Compiler: 10.1
MMOCR: 0.2.1+8227fec


mmcv-full          1.3.8
mmdet              2.14.0
mmocr              0.2.1               /home/jovyan/mmocr

Resolving patch:
diff --git a/mmocr/utils/ocr.py b/mmocr/utils/ocr.py
--- a/mmocr/utils/ocr.py
+++ b/mmocr/utils/ocr.py
@@ -275,8 +275,7 @@ def __init__(self,
             },
             'RobustScanner': {
                 'config': 'robust_scanner/robustscanner_r31_academic.py',
-                'ckpt':
-                'robustscanner/robustscanner_r31_academic-5f05874f.pth'
+                'ckpt': 'robustscanner/robustscanner_r31_academic-5f05874f.pth'
             },
             'SEG': {
                 'config': 'seg/seg_r31_1by16_fpnocr_academic.py',


Test patch:
diff --git a/tools/test.py b/tools/test.py
--- a/tools/test.py
+++ b/tools/test.py
@@ -127,7 +127,8 @@ def main():
     # set cudnn_benchmark
     if cfg.get('cudnn_benchmark', False):
         torch.backends.cudnn.benchmark = True
-    cfg.model.pretrained = None
+    if cfg.model.get('pretrained'):
+        cfg.model.pretrained = None
     if cfg.model.get('neck'):
         if isinstance(cfg.model.neck, list):
             for neck_cfg in cfg.model.neck: