Skip to content

Commit

Permalink
[Fix] Remove dependcy mmdet when do not use MaskFormerHead and `MMD…
Browse files Browse the repository at this point in the history
…ET_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
  • Loading branch information
MeowZheng committed Dec 30, 2022
1 parent 115552d commit d88f393
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mmseg/models/decode_heads/mask2former_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
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
Expand Down
3 changes: 2 additions & 1 deletion mmseg/models/decode_heads/maskformer_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
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
Expand Down

0 comments on commit d88f393

Please sign in to comment.