Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with encoder.py #79

Open
CluelessIT opened this issue Feb 18, 2021 · 1 comment
Open

Issue with encoder.py #79

CluelessIT opened this issue Feb 18, 2021 · 1 comment

Comments

@CluelessIT
Copy link

CluelessIT commented Feb 18, 2021

Would like to clarify the input for _get_anchor_boxes function under encoder.py is a tuple or a int?

As I realised after the code went to line 50 it is not able to assign the values to fm_w and fm_h.

def _get_anchor_boxes(self**, input_size):**
        '''Compute anchor boxes for each feature map.
        Args:
          input_size: (tensor) model input size of (w,h).
        Returns:
          boxes: (list) anchor boxes for each feature map. Each of size [#anchors,4],
                        where #anchors = fmw * fmh * #anchors_per_cell
        '''
        num_fms = len(self.anchor_areas)
        **fm_sizes = [(input_size/pow(2.,i+3)).ceil() for i in range(num_fms)]  # p3 -> p7 feature map sizes**

        boxes = []
        for i in range(num_fms):
            **fm_size = fm_sizes[i]**
            grid_size = input_size / fm_size
            **fm_w, fm_h = int(fm_size[0]), int(fm_size[1])**
            xy = meshgrid(fm_w,fm_h) + 0.5  # [fm_h*fm_w, 2]
            xy = (xy*grid_size).view(fm_h,fm_w,1,2).expand(fm_h,fm_w,9,2)
            wh = self.anchor_wh[i].view(1,1,9,2).expand(fm_h,fm_w,9,2)
            box = torch.cat([xy,wh], 3)  # [x,y,w,h]
            boxes.append(box.view(-1,4))
        return torch.cat(boxes, 0)

I assign input_size as a integer for example 448, and the output of fm_size is a list of elements. Not a list of tuples.
So I am confused as to what should be the values inside fm_size. And in general the purpose of doing this encoder.py

If anybody is able to explain to me the purpose of it that would be great! Thank you so much!

@CluelessIT
Copy link
Author

Would like to clarify the input for _get_anchor_boxes function under encoder.py is a tuple or a int?

As I realised after the code went to line 50 it is not able to assign the values to fm_w and fm_h.

def _get_anchor_boxes(self**, input_size):**
        '''Compute anchor boxes for each feature map.
        Args:
          input_size: (tensor) model input size of (w,h).
        Returns:
          boxes: (list) anchor boxes for each feature map. Each of size [#anchors,4],
                        where #anchors = fmw * fmh * #anchors_per_cell
        '''
        num_fms = len(self.anchor_areas)
        **fm_sizes = [(input_size/pow(2.,i+3)).ceil() for i in range(num_fms)]  # p3 -> p7 feature map sizes**

        boxes = []
        for i in range(num_fms):
            **fm_size = fm_sizes[i]**
            grid_size = input_size / fm_size
            **fm_w, fm_h = int(fm_size[0]), int(fm_size[1])**
            xy = meshgrid(fm_w,fm_h) + 0.5  # [fm_h*fm_w, 2]
            xy = (xy*grid_size).view(fm_h,fm_w,1,2).expand(fm_h,fm_w,9,2)
            wh = self.anchor_wh[i].view(1,1,9,2).expand(fm_h,fm_w,9,2)
            box = torch.cat([xy,wh], 3)  # [x,y,w,h]
            boxes.append(box.view(-1,4))
        return torch.cat(boxes, 0)

I assign input_size as a integer for example 448, and the output of fm_size is a list of elements. Not a list of tuples.
So I am confused as to what should be the values inside fm_size. And in general the purpose of doing this encoder.py

If anybody is able to explain to me the purpose of it that would be great! Thank you so much!

@kuangliu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant