open-mmlab / mmocr

OpenMMLab Text Detection, Recognition and Understanding Toolbox
https://mmocr.readthedocs.io/en/dev-1.x/
Apache License 2.0
4.18k stars 735 forks source link

[Bug] AssertionError: MMDetection 3.2.0 is incompatible with MMOCR 1.0.1. #1998

Closed 02shanks closed 8 months ago

02shanks commented 8 months ago

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

main branch https://github.com/open-mmlab/mmocr

Environment

Traceback (most recent call last): File "/content/mmocr/mmocr/utils/collect_env.py", line 5, in import mmocr File "/content/mmocr/mmocr/init.py", line 50, in and mmdet_version < digit_version(mmdet_maximum_version)), \ AssertionError: MMDetection 3.2.0 is incompatible with MMOCR 1.0.1. Please use MMDetection >= 3.0.0rc5, < 3.2.0 instead.

Reproduces the problem - code sample

First I installed all necessary libraries

!pip install -U openmim !mim install mmengine !mim install 'mmcv>=2.0.0rc1' !mim install 'mmdet>=3.0.0rc0'

Then

!git clone https://github.com/open-mmlab/mmocr.git %cd mmocr !pip install -v -e .

Then

from mmocr.apis import MMOCRInferencer ocr = MMOCRInferencer(det='DBNet', rec='CRNN') ocr('demo/demo_text_ocr.jpg', show=True, print_result=True)

Reproduces the problem - command or script

%%bash !pip install -U openmim !mim install mmengine !mim install 'mmcv>=2.0.0rc1' !mim install 'mmdet>=3.0.0rc5'

then

!git clone https://github.com/open-mmlab/mmocr.git %cd mmocr !pip install -v -e .

Reproduces the problem - error message

AssertionError: MMDetection 3.2.0 is incompatible with MMOCR 1.0.1. Please use MMDetection >= 3.0.0rc5, < 3.2.0 instead.

Additional information

I am using colab notebook where I encounter this error After running from mmocr.apis import MMOCRInferencer I received AssertionError: MMDetection 3.2.0 is incompatible with MMOCR 1.0.1. Please use MMDetection >= 3.0.0rc5, < 3.2.0 instead.

I changed from !mim install 'mmdet>=3.0.0rc0' to !mim install 'mmdet>=3.0.0rc5'

but still I get same error!

letruongngochai commented 8 months ago

I've got the same problem

02shanks commented 8 months ago

I resolved this issue just by lowering pytorch version to 2.0. Check link for suitable version

##check version 
!python -c 'import torch;print(torch.__version__);print(torch.version.cuda)'

!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118 -q

##then
!pip3 install openmim
!git clone https://github.com/open-mmlab/mmocr.git
%cd mmocr
!mim install -e .

##finally
from mmocr.apis import MMOCRInferencer
ocr = MMOCRInferencer(det='DBNet', rec='CRNN')
ocr('demo/demo_text_ocr.jpg', show=True, print_result=True)

This worked for me without any error in any piece of code

02shanks commented 8 months ago

It was mainly due to mmcv and pytorch version issue which is explained in this issue. This dependency issue would be solved within weeks as mentioned in issue itself Hope so it might help other to!

JumpingRobin commented 6 months ago

I have lowered my pytorch version, but the problem is still there. `AssertionError: MMDetection 3.2.0 is incompatible with MMOCR 1.0.1. Please use MMDetection >= 3.0.0rc5, < 3.2.0 instead.

import torch print(torch.version) 2.0.0 print(torch.version.cuda) 11.7`

Problem solved! mim install 'mmdet<3.2.0' This seems to solve this problem! Have a try!

raintowing commented 5 months ago

You can comment out the Assert code to solve the problem temporarily.