mirror of
https://github.com/open-mmlab/mmsegmentation.git
synced 2025-06-03 22:03:48 +08:00
[Fix] Remove dependcy mmdet when do not use MaskFormerHead
and MMDET_Mask2FormerHead
(#2448)
## Motivation Calling `mmseg.utils.register_all_modules` will import `MaskFormerHead` and `Mask2FormerHead`, it will crash if mmdet is not installed as `None` cannot be initialized. ## Modification - Modify `MMDET_MaskFormerHead=BaseModule` and `MMDET_Mask2FormerHead = BaseModule` when cannot import from mmdet
This commit is contained in:
parent
115552d5ea
commit
d88f393ffa
@ -4,12 +4,13 @@ from typing import List, Tuple
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from mmengine.model import BaseModule
|
||||
|
||||
try:
|
||||
from mmdet.models.dense_heads import \
|
||||
Mask2FormerHead as MMDET_Mask2FormerHead
|
||||
except ModuleNotFoundError:
|
||||
MMDET_Mask2FormerHead = None
|
||||
MMDET_Mask2FormerHead = BaseModule
|
||||
|
||||
from mmengine.structures import InstanceData
|
||||
from torch import Tensor
|
||||
|
@ -4,11 +4,12 @@ from typing import List, Tuple
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from mmengine.model import BaseModule
|
||||
|
||||
try:
|
||||
from mmdet.models.dense_heads import MaskFormerHead as MMDET_MaskFormerHead
|
||||
except ModuleNotFoundError:
|
||||
MMDET_MaskFormerHead = None
|
||||
MMDET_MaskFormerHead = BaseModule
|
||||
|
||||
from mmengine.structures import InstanceData
|
||||
from torch import Tensor
|
||||
|
Loading…
x
Reference in New Issue
Block a user