Skip to content

Commit

Permalink
fix ci (open-mmlab#9647)
Browse files Browse the repository at this point in the history
  • Loading branch information
jshilong authored and yumion committed Jan 31, 2024
1 parent 956337c commit 1275fe8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion mmdet/models/detectors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from .atss import ATSS
from .autoassign import AutoAssign
from .base import BaseDetector
from .boxinst import BoxInst
from .base_detr import DetectionTransformer
from .boxinst import BoxInst
from .cascade_rcnn import CascadeRCNN
from .centernet import CenterNet
from .condinst import CondInst
Expand Down
4 changes: 2 additions & 2 deletions tests/test_models/test_detectors/test_conditional_detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from mmengine.structures import InstanceData

from mmdet.models import build_detector
from mmdet.registry import MODELS
from mmdet.structures import DetDataSample
from mmdet.testing import get_detector_cfg
from mmdet.utils import register_all_modules
Expand Down Expand Up @@ -32,7 +32,7 @@ def test_conditional_detr_head_loss(self):
config = get_detector_cfg(
'conditional_detr/conditional-detr_r50_8xb2-50e_coco.py')

model = build_detector(config)
model = MODELS.build(config)
model.init_weights()
random_image = torch.rand(1, 3, s, s)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_models/test_detectors/test_dab_detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from mmengine.structures import InstanceData

from mmdet.models import build_detector
from mmdet.registry import MODELS
from mmdet.structures import DetDataSample
from mmdet.testing import get_detector_cfg
from mmdet.utils import register_all_modules
Expand All @@ -31,7 +31,7 @@ def test_dab_detr_head_loss(self):

config = get_detector_cfg('dab_detr/dab-detr_r50_8xb2-50e_coco.py')

model = build_detector(config)
model = MODELS.build(config)
model.init_weights()
random_image = torch.rand(1, 3, s, s)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_models/test_detectors/test_deformable_detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from mmengine.structures import InstanceData

from mmdet.models import build_detector
from mmdet.registry import MODELS
from mmdet.structures import DetDataSample
from mmdet.testing import get_detector_cfg
from mmdet.utils import register_all_modules
Expand Down Expand Up @@ -41,7 +41,7 @@ def test_deformable_detr_head_loss(self):
]

for config in configs:
model = build_detector(config)
model = MODELS.build(config)
model.init_weights()
random_image = torch.rand(1, 3, s, s)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_models/test_detectors/test_detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from mmengine.structures import InstanceData

from mmdet.models import build_detector
from mmdet.registry import MODELS
from mmdet.structures import DetDataSample
from mmdet.testing import get_detector_cfg
from mmdet.utils import register_all_modules
Expand All @@ -31,7 +31,7 @@ def test_detr_head_loss(self):

config = get_detector_cfg('detr/detr_r50_8xb2-150e_coco.py')

model = build_detector(config)
model = MODELS.build(config)
model.init_weights()
random_image = torch.rand(1, 3, s, s)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_models/test_detectors/test_dino.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from mmengine.structures import InstanceData

from mmdet.models import build_detector
from mmdet.registry import MODELS
from mmdet.structures import DetDataSample
from mmdet.testing import get_detector_cfg
from mmdet.utils import register_all_modules
Expand All @@ -30,7 +30,7 @@ def test_dino_head_loss(self):
configs = [get_detector_cfg('dino/dino-4scale_r50_8xb2-12e_coco.py')]

for config in configs:
model = build_detector(config)
model = MODELS.build(config)
model.init_weights()
random_image = torch.rand(1, 3, s, s)

Expand Down
18 changes: 9 additions & 9 deletions tests/test_models/test_detectors/test_maskformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from parameterized import parameterized

from mmdet.models import build_detector
from mmdet.registry import MODELS
from mmdet.structures import DetDataSample
from mmdet.testing._utils import demo_mm_inputs, get_detector_cfg
from mmdet.utils import register_all_modules
Expand Down Expand Up @@ -49,15 +49,15 @@ def _create_model_cfg(self):

def test_init(self):
model_cfg = self._create_model_cfg()
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)
detector.init_weights()
assert detector.backbone
assert detector.panoptic_head

@parameterized.expand([('cpu', ), ('cuda', )])
def test_forward_loss_mode(self, device):
model_cfg = self._create_model_cfg()
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)

if device == 'cuda' and not torch.cuda.is_available():
return unittest.skip('test requires GPU and torch+cuda')
Expand All @@ -77,7 +77,7 @@ def test_forward_loss_mode(self, device):
@parameterized.expand([('cpu', ), ('cuda', )])
def test_forward_predict_mode(self, device):
model_cfg = self._create_model_cfg()
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)
if device == 'cuda' and not torch.cuda.is_available():
return unittest.skip('test requires GPU and torch+cuda')
detector = detector.to(device)
Expand All @@ -98,7 +98,7 @@ def test_forward_predict_mode(self, device):
@parameterized.expand([('cpu', ), ('cuda', )])
def test_forward_tensor_mode(self, device):
model_cfg = self._create_model_cfg()
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)
if device == 'cuda' and not torch.cuda.is_available():
return unittest.skip('test requires GPU and torch+cuda')
detector = detector.to(device)
Expand Down Expand Up @@ -153,7 +153,7 @@ def _create_model_cfg(self, cfg_path):
def test_init(self):
model_cfg = self._create_model_cfg(
'mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py')
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)
detector.init_weights()
assert detector.backbone
assert detector.panoptic_head
Expand All @@ -168,7 +168,7 @@ def test_forward_loss_mode(self, device, cfg_path):
print(device, cfg_path)
with_semantic = 'panoptic' in cfg_path
model_cfg = self._create_model_cfg(cfg_path)
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)

if device == 'cuda' and not torch.cuda.is_available():
return unittest.skip('test requires GPU and torch+cuda')
Expand All @@ -194,7 +194,7 @@ def test_forward_loss_mode(self, device, cfg_path):
def test_forward_predict_mode(self, device, cfg_path):
with_semantic = 'panoptic' in cfg_path
model_cfg = self._create_model_cfg(cfg_path)
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)
if device == 'cuda' and not torch.cuda.is_available():
return unittest.skip('test requires GPU and torch+cuda')
detector = detector.to(device)
Expand All @@ -221,7 +221,7 @@ def test_forward_predict_mode(self, device, cfg_path):
def test_forward_tensor_mode(self, device, cfg_path):
with_semantic = 'panoptic' in cfg_path
model_cfg = self._create_model_cfg(cfg_path)
detector = build_detector(model_cfg)
detector = MODELS.build(model_cfg)
if device == 'cuda' and not torch.cuda.is_available():
return unittest.skip('test requires GPU and torch+cuda')
detector = detector.to(device)
Expand Down

0 comments on commit 1275fe8

Please sign in to comment.