icevision
icevision copied to clipboard
Compatibility to mmdet has been removed
🐛 Bug
Describe the bug My team and I utilise databricks as our main platform for development. As such we are required to install our dependencies on a daily basis. This should be fine except for some unique behaviours that are breaking the compatibility of mmdet and icevision. This bug is two problems that are essentially the same result.
This is what we have learnt about mmcv and mmdet
- mmcv requires installing with precompiled torch and cuda, using the -full https://... option. This requires knowing the versions on databricks.
- To get the version run:
- import torch
- print(torch.version)
- If you need to change the version cuda or torch for mmcv-full, then you need to uninstall it if the python version is unchanged.
- Alternatively, --force-reinstall can be added to the pip install line to always reinstall this requirement
icevision==0.12.0 is not updated to changes in the api of mmdet in several places:
- 'MultiScaleDeformableAttention'. mmdet==2.5.0 is the last release before backwards compatibility was dropped
- 'CSPDarknet'. mmdet==2.15.1 is the first place this is found, however this release has a circular reference which gets hit in from ..utils import CSPLayer. This does not resolve for any versions between 2.15.1 and 2.22.0 (latest at the time of writing)
- this does not change when downgrading icevision to 0.11.0
- icevision is not currently compatible with mmdet>=2.15.1
- icevision is not compatible with mmdet <=2.15.0 as there is hardcoded references to CSPDarknet in the code base
To Reproduce Steps to reproduce the behavior:
- Install the following dependencies (Many different versions of this particular setup have been used with almost all combinations of mmdet and mmcv-full installations):
- pip install fastai==2.5.3
- pip install --force-reinstall mmcv-full==1.3.16 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.10.0/index.html
- pip install mmdet==2.15.0
- pip install icevision==0.11.0
- Attempt to import the below
import gc
import os
import shutil
import multiprocessing as mp
import glob
import ast
import pandas as pd
from itertools import repeat
from icevision.all import *
from icevision.engines.fastai import *
from multiprocessing import Process, Manager, Pool
from icevision.models.ross import *
from icevision.models.mmdet.common import loss_fn
from icevision.models.mmdet.fastai.learner import *
Expected behaviour Everything to be installed without errors.
Actual behaviour One of the following errors (depending on which mmcv and mmdet versions are installed):
- (with the above installs) - ModuleNotFoundError: No module named 'mmdet.models.backbones.csp_darknet'
- (with mmdet==2.22.0) - ImportError: cannot import name 'CSPLayer' from 'mmdet.models.utils' (/databricks/python/lib/python3.8/site-packages/mmdet/models/utils/init.py)
- (with mmcv==3.18.0 and mmdet==2.22.0) 'MultiScaleDeformableAttention' from 'mmcv.cnn.bricks.transformer'
Desktop (please complete the following information):
- Linux version: 5.4.0-1067-azure
@dnth @ai-fast-track have you guys stumbled upon these issues?
I followed the steps in To Reproduce and I face the same error. However, I managed to solve the error with the following.
First reinstall pytorch to match the version specified when installing mmcv (in the mmcv installation the torch version specified is 1.10.0). pip install icevision==0.11.0
installs torch==1.10.2
which is a mismatch to the one of mmcv. Mmcv is very notorious with matching torch and cuda version to make it work.
So run the following
pip install torch==1.10.0+cu111 torchvision==0.11.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
Next, update mmdet to more recent version. I tried with
pip install mmdet==2.17.0
I no longer face any of the errors. Let us know if it works for you :)
I'm also encountering this error. @dnth 's solution worked for me.
I'm also encountering this error. @dnth 's solution worked for me.