Skip to content

Commit

Permalink
Add unitests for detr 3.x (#9089)
Browse files Browse the repository at this point in the history
  • Loading branch information
LYMDLUT authored and jshilong committed Jan 19, 2023
1 parent 4d30934 commit 5594cb5
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 744 deletions.
28 changes: 27 additions & 1 deletion mmdet/models/detectors/deformable_detr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import math
from typing import Dict, Tuple
from typing import Dict, List, Tuple

import torch
import torch.nn.functional as F
Expand Down Expand Up @@ -539,3 +539,29 @@ def get_proposal_pos_embed(proposals: Tensor,
pos = torch.stack((pos[:, :, :, 0::2].sin(), pos[:, :, :, 1::2].cos()),
dim=4).flatten(2)
return pos

def _forward(
self,
batch_inputs: Tensor,
batch_data_samples: OptSampleList = None) -> Tuple[List[Tensor]]:
"""Network forward process. Usually includes backbone, neck and head
forward without any post-processing.Overwrite to pop
'enc_outputs_class' and 'enc_outputs_coord'.
Args:
batch_inputs (Tensor): Inputs, has shape (bs, dim, H, W).
batch_data_samples (List[:obj:`DetDataSample`], optional): The
batch data samples. It usually includes information such
as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`.
Defaults to None.
Returns:
tuple[Tensor]: A tuple of features from ``bbox_head`` forward.
"""
img_feats = self.extract_feat(batch_inputs)
head_inputs_dict = self.forward_transformer(img_feats,
batch_data_samples)
head_inputs_dict.pop('enc_outputs_class')
head_inputs_dict.pop('enc_outputs_coord')
results = self.bbox_head.forward(**head_inputs_dict)
return results
132 changes: 0 additions & 132 deletions tests/test_models/test_dense_heads/test_deformable_detr_head.py

This file was deleted.

134 changes: 0 additions & 134 deletions tests/test_models/test_dense_heads/test_detr_head.py

This file was deleted.

Loading

0 comments on commit 5594cb5

Please sign in to comment.