You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fast_rcnn.py 2.2 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. from ..builder import DETECTORS
  3. from .two_stage import TwoStageDetector
  4. @DETECTORS.register_module()
  5. class FastRCNN(TwoStageDetector):
  6. """Implementation of `Fast R-CNN <https://arxiv.org/abs/1504.08083>`_"""
  7. def __init__(self,
  8. backbone,
  9. roi_head,
  10. train_cfg,
  11. test_cfg,
  12. neck=None,
  13. pretrained=None,
  14. init_cfg=None):
  15. super(FastRCNN, self).__init__(
  16. backbone=backbone,
  17. neck=neck,
  18. roi_head=roi_head,
  19. train_cfg=train_cfg,
  20. test_cfg=test_cfg,
  21. pretrained=pretrained,
  22. init_cfg=init_cfg)
  23. def forward_test(self, imgs, img_metas, proposals, **kwargs):
  24. """
  25. Args:
  26. imgs (List[Tensor]): the outer list indicates test-time
  27. augmentations and inner Tensor should have a shape NxCxHxW,
  28. which contains all images in the batch.
  29. img_metas (List[List[dict]]): the outer list indicates test-time
  30. augs (multiscale, flip, etc.) and the inner list indicates
  31. images in a batch.
  32. proposals (List[List[Tensor]]): the outer list indicates test-time
  33. augs (multiscale, flip, etc.) and the inner list indicates
  34. images in a batch. The Tensor should have a shape Px4, where
  35. P is the number of proposals.
  36. """
  37. for var, name in [(imgs, 'imgs'), (img_metas, 'img_metas')]:
  38. if not isinstance(var, list):
  39. raise TypeError(f'{name} must be a list, but got {type(var)}')
  40. num_augs = len(imgs)
  41. if num_augs != len(img_metas):
  42. raise ValueError(f'num of augmentations ({len(imgs)}) '
  43. f'!= num of image meta ({len(img_metas)})')
  44. if num_augs == 1:
  45. return self.simple_test(imgs[0], img_metas[0], proposals[0],
  46. **kwargs)
  47. else:
  48. # TODO: support test-time augmentation
  49. assert NotImplementedError

No Description

Contributors (3)