mmocr
mmocr copied to clipboard
[Bug] error: (-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) in function 'cv::convexHull'
Prerequisite
- [X] I have searched Issues and Discussions but cannot get the expected help.
- [X] The bug has not been fixed in the latest version (0.x) or latest version (1.x).
Task
I have modified the scripts/configs, or I'm working on my own tasks/models/datasets.
Branch
main branch https://github.com/open-mmlab/mmocr
Environment
sys.platform: win32 Python: 3.8.16 (default, Jun 12 2023, 21:00:42) [MSC v.1916 64 bit (AMD64)] CUDA available: True numpy_random_seed: 2147483648 GPU 0: NVIDIA GeForce GTX 1080 Ti CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3 NVCC: Cuda compilation tools, release 11.3, V11.3.109 MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.35.32215 版 GCC: n/a PyTorch: 1.10.1 PyTorch compiling details: PyTorch built with:
- C++ Version: 199711
- MSVC 192829337
- Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
- OpenMP 2019
- LAPACK is enabled (usually provided by MKL)
- CPU capability usage: AVX2
- CUDA Runtime 11.3
- 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_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
- CuDNN 8.2
- Magma 2.5.4
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, CXX_COMPILER=C:/cb/pytorch_1000000000000/work/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -IC:/cb/pytorch_1000000000000/work/mkl/include -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON,
TorchVision: 0.11.2 OpenCV: 4.8.0 MMEngine: 0.8.0 MMOCR: 1.0.1+1dcd6fa
Reproduces the problem - code sample
when I use text_repr_type='quad'
in maskrcnn config,
I get error: (-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) in function 'cv::convexHull'
bug appears on :
file : mmocr/models/textdet/detectors/mmdet_wrapper.py
line rect = cv2.minAreaRect(poly)
model = dict(
type='MMDetWrapper',
text_repr_type='quad',
cfg=dict(
type='MaskRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[
123.675,
116.28,
103.53,
],
std=[
58.395,
57.12,
57.375,
],
if self.text_repr_type == 'quad':
for j, poly in enumerate(filterd_polygons):
rect = cv2.minAreaRect(poly)
vertices = cv2.boxPoints(rect)
poly = vertices.flatten()
filterd_polygons[j] = poly
Reproduces the problem - command or script
python .\tools\test.py configs_myself/mask-rcnn_resnet50_fpn_160e_mini_icdar2015.py work_dirs/mask-rcnn_resnet50_fpn_160e_icdar2015/epoch_20.pth --show-dir imgs/
Reproduces the problem - error message
Traceback (most recent call last):
File "C:\Users\gh\miniconda3\envs\mmocr\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "C:\Users\gh\miniconda3\envs\mmocr\lib\site-packages\mmengine\runner\loops.py", line 454, in run_iter
outputs = self.runner.model.test_step(data_batch)
File "C:\Users\gh\miniconda3\envs\mmocr\lib\site-packages\mmengine\model\base_model\base_model.py", line 145, in test_step
return self._run_forward(data, mode='predict') # type: ignore
File "C:\Users\gh\miniconda3\envs\mmocr\lib\site-packages\mmengine\model\base_model\base_model.py", line 340, in _run_forward
results = self(**data, mode=mode)
File "C:\Users\gh\miniconda3\envs\mmocr\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\gh\PycharmProjects\mmocr\mmocr\models\textdet\detectors\mmdet_wrapper.py", line 86, in forward
results = self.adapt_predictions(results, ocr_data_samples)
File "C:\Users\gh\PycharmProjects\mmocr\mmocr\models\textdet\detectors\mmdet_wrapper.py", line 141, in adapt_predictions
rect = cv2.minAreaRect(poly)
cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\convhull.cpp:143: error: (-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) in function 'cv::convexHull'
python-BaseException
Process finished with exit code 1
Additional information
No response
Hi @ETOPDC Here is a quick fix for this issue
if self.text_repr_type == 'quad':
for j, poly in enumerate(filterd_polygons):
poly = poly.reshape(-1, 2)
rect = cv2.minAreaRect(poly)
vertices = cv2.boxPoints(rect)
poly = vertices.flatten()
filterd_polygons[j] = poly
Feel free to raise a PR to help us fix it.