def filter_local()

in lib/model/HGPIFuMRNet.py [0:0]


    def filter_local(self, images, rect=None):
        '''
        apply a fully convolutional network to images.
        the resulting feature will be stored.
        args:
            images: [B1, B2, C, H, W]
        '''
        nmls = []
        try:
            if self.netG.opt.use_front_normal:
                nmls.append(self.netG.nmlF)
            if self.netG.opt.use_back_normal:
                nmls.append(self.netG.nmlB)
        except:
            pass

        if len(nmls):
            nmls = nn.Upsample(size=(self.opt.loadSizeBig,self.opt.loadSizeBig), mode='bilinear', align_corners=True)(torch.cat(nmls,1))
            
            # it's kind of damn way.
            if rect is None:
                images = torch.cat([images, nmls[:,None].expand(-1,images.size(1),-1,-1,-1)], 2)
            else:
                nml = []
                for i in range(rect.size(0)):
                    for j in range(rect.size(1)):
                        x1, y1, x2, y2 = rect[i,j]
                        tmp = nmls[i,:,y1:y2,x1:x2]
                        nml.append(nmls[i,:,y1:y2,x1:x2])
                nml = torch.stack(nml, 0).view(*rect.shape[:2],*nml[0].size())
                images = torch.cat([images, nml], 2)

        self.im_feat_list, self.normx = self.image_filter(images.view(-1,*images.size()[2:]))
        if not self.training:
            self.im_feat_list = [self.im_feat_list[-1]]