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.

cascade_rcnn.py 1.7 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. from ..builder import DETECTORS
  3. from .two_stage import TwoStageDetector
  4. @DETECTORS.register_module()
  5. class CascadeRCNN(TwoStageDetector):
  6. r"""Implementation of `Cascade R-CNN: Delving into High Quality Object
  7. Detection <https://arxiv.org/abs/1906.09756>`_"""
  8. def __init__(self,
  9. backbone,
  10. neck=None,
  11. rpn_head=None,
  12. roi_head=None,
  13. train_cfg=None,
  14. test_cfg=None,
  15. pretrained=None,
  16. init_cfg=None):
  17. super(CascadeRCNN, self).__init__(
  18. backbone=backbone,
  19. neck=neck,
  20. rpn_head=rpn_head,
  21. roi_head=roi_head,
  22. train_cfg=train_cfg,
  23. test_cfg=test_cfg,
  24. pretrained=pretrained,
  25. init_cfg=init_cfg)
  26. def show_result(self, data, result, **kwargs):
  27. """Show prediction results of the detector.
  28. Args:
  29. data (str or np.ndarray): Image filename or loaded image.
  30. result (Tensor or tuple): The results to draw over `img`
  31. bbox_result or (bbox_result, segm_result).
  32. Returns:
  33. np.ndarray: The image with bboxes drawn on it.
  34. """
  35. if self.with_mask:
  36. ms_bbox_result, ms_segm_result = result
  37. if isinstance(ms_bbox_result, dict):
  38. result = (ms_bbox_result['ensemble'],
  39. ms_segm_result['ensemble'])
  40. else:
  41. if isinstance(result, dict):
  42. result = result['ensemble']
  43. return super(CascadeRCNN, self).show_result(data, result, **kwargs)

No Description

Contributors (1)