(self, x, locs)
| 127 | |
| 128 | |
| 129 | def forward(self, x, locs): |
| 130 | w_b = [] |
| 131 | extend_W = 32*4 |
| 132 | max_lr_width = x.size(3) |
| 133 | for b in range(locs.size(0)): #locs: 0~2048 |
| 134 | x_for_w = [] |
| 135 | for c in range(locs.size(1)): |
| 136 | center_loc = (locs[b][c]/4).int() |
| 137 | start_x = max(0, center_loc - extend_W//2) |
| 138 | end_x = min(center_loc + extend_W//2, max_lr_width) |
| 139 | crop_x = x[b:b+1, :, :, start_x:end_x].detach() |
| 140 | crop_x = self._check_outliers_pad(crop_x, start_x, end_x, max_lr_width, center_loc, extend_W) # |
| 141 | |
| 142 | x_for_w.append(crop_x) |
| 143 | # crop_x[...,62:66] = 1 |
| 144 | # save_image((crop_x+1)/2, 'trs_{}.png'.format(c)) |
| 145 | |
| 146 | x_for_w = torch.cat(x_for_w, dim=0) |
| 147 | |
| 148 | x_c1 = self.conv1(x_for_w) #1 |
| 149 | x_c1 = self.relu(x_c1) |
| 150 | x_l1 = self.layer1(x_c1) #2 |
| 151 | x_l2 = self.layer2(x_l1) #1 [2, 64, 16, 256]) |
| 152 | x_l3 = self.layer3(x_l2) #2 torch.Size([2, 128, 8, 128] |
| 153 | x_l4 = self.layer4(x_l3) #1 torch.Size([2, 256, 8, 128]) |
| 154 | x_l5 = self.layer5(x_l4) #2, torch.Size([2, 512, 4, 64]) |
| 155 | pyramid_x1 = _upsample_add(x_l5, self.layer256_to_512(x_l4)) |
| 156 | pyramid_x = self.layer512_to_outdim(pyramid_x1) |
| 157 | w_each_b = self.feature2w(pyramid_x.view(pyramid_x.size(0), -1)) # |
| 158 | |
| 159 | w_c = w_each_b |
| 160 | w_b.append(w_c) |
| 161 | w_b = torch.stack(w_b, dim=0) |
| 162 | |
| 163 | return w_b |
| 164 | |
| 165 | |
| 166 | |
| 167 | # w_b = [] |
| 168 | # for b in range(locs.size(0)): #locs: 0~2048 |
| 169 | # w_c = [] |
| 170 | # for c in range(locs.size(1)): |
| 171 | # if locs[b][c] < 2048: |
| 172 | # center_loc = (locs[b][c]/4).int() # 32*512 |
| 173 | # start_x = center_loc - 16 |
| 174 | # end_x = center_loc + 16 |
| 175 | |
| 176 | # crop_x0 = x[b:b+1, :, :, start_x:end_x].clone() |
| 177 | # crop_x = self._check_outliers_pad(crop_x0, start_x, end_x) # 1, 512, 4, 4 or 1, 512, 8, 8 |
| 178 | |
| 179 | # # save_image(crop_x[0], 'ss_{}.png'.format(c)) |
| 180 | # x_c1 = self.conv1(crop_x) #1 |
| 181 | # x_c1 = self.relu(x_c1) |
| 182 | # x_l1 = self.layer1(x_c1) #2 |
| 183 | # x_l2 = self.layer2(x_l1) #1 [2, 64, 16, 256]) |
| 184 | # x_l3 = self.layer3(x_l2) #2 torch.Size([2, 128, 8, 128] |
| 185 | # x_l4 = self.layer4(x_l3) #1 torch.Size([2, 256, 8, 128]) |
| 186 | # x_l5 = self.layer5(x_l4) #2, torch.Size([2, 512, 4, 64]) |
nothing calls this directly
no test coverage detected