728x90
반응형

 

 

mmdetection 모듈 쓰다가 mlvl 의 의미가 궁금해서 알아보았다. 

 

class mmdet.core.anchor.MlvlPointGenerator(strides, offset=0.5)

 

multi-level (Mlvl) 이였다....

 

주로 2D Points 기반 검출기의 Multi-level(Mlvl) Feature Map 을 위한 point 를 생성할 때 사용하며, 

Object Detection 분야에서 Anchor Free 스타일의 헤더(Header) 에서 주로 사용된다. 

 

    def get_points(self, featmap_sizes, dtype, device, flatten=False):
        """Get points according to feature map sizes.

        Args:
            featmap_sizes (list[tuple]): Multi-level feature map sizes.
            dtype (torch.dtype): Type of points.
            device (torch.device): Device of points.

        Returns:
            tuple: points of each image.
        """
        mlvl_points = []
        for i in range(len(featmap_sizes)):
            mlvl_points.append(
                self._get_points_single(featmap_sizes[i], self.strides[i],
                                        dtype, device, flatten))
        return mlvl_points

 

 

    def _get_points_single(self,
                           featmap_size,
                           stride,
                           dtype,
                           device,
                           flatten=False):
        """Get points of a single scale level."""
        h, w = featmap_size
        # First create Range with the default dtype, than convert to
        # target `dtype` for onnx exporting.
        x_range = torch.arange(w, device=device).to(dtype)
        y_range = torch.arange(h, device=device).to(dtype)
        y, x = torch.meshgrid(y_range, x_range)
        if flatten:
            y = y.flatten()
            x = x.flatten()
        return y, x
728x90
반응형