(self, cls_indices, seg_score, boxes)
:param cls_indices: [num_boxes x 1]
        :param seg_score: [1 x num_seg_classes x h x w]
        :return: seg_energy: [1 x (num_seg_classes - num_things_classes + num_boxes) x h x w]
:param cls_indices: [num_boxes x 1]
        :param seg_score: [1 x num_seg_classes x h x w]
        :return: seg_energy: [1 x (num_seg_classes - num_things_classes + num_boxes) x h x w]
: param cls_indices : [ num_boxes x 1 ] : param seg_score : [ 1 x num_seg_classes x h x w ] : return : seg_energy : [ 1 x ( num_seg_classes - num_things_classes + num_boxes ) x h x w ]
def forward(self, cls_indices, seg_score, boxes):
        """
        :param cls_indices: [num_boxes x 1]
        :param seg_score: [1 x num_seg_classes x h x w]
        :return: seg_energy: [1 x (num_seg_classes - num_things_classes + num_boxes) x h x w]
        """
        assert seg_score.shape[0] == 1, "only support batch size = 1"
        cls_indices = cls_indices.cpu().numpy()
        # seg_energy: STUFF classes only
        seg_stuff_energy = seg_score[[0], :self.num_stuff_classes, :, :] # ONLY STUFF CLASSES (11)

        boxes = boxes.cpu().numpy()
        boxes = boxes[:, 1:] * self.box_scale

        if cls_indices.size == 0:
            return seg_energy, torch.ones_like(seg_energy[[0], [0], :, :]).view(1, 1, seg_energy.shape[2], seg_energy.shape[3]) * -10
        else:
            seg_inst_energy = torch.zeros((seg_score.shape[0], cls_indices.shape[0], seg_score.shape[2], seg_score.shape[3]), device=seg_score.device)
            for i in range(cls_indices.shape[0]):
                if cls_indices[i] == 0:
                    continue
                y0 = int(boxes[i][1])
                y1 = int(boxes[i][3].round()+1)
                x0 = int(boxes[i][0])
                x1 = int(boxes[i][2].round()+1)
                seg_inst_energy[0, i, y0: y1, x0: x1] = seg_score[0, self.class_mapping[cls_indices[i]], y0: y1, x0: x1]

            return seg_stuff_energy, seg_inst_energy
def forward ( self , cls_indices , seg_score , boxes ) : assert seg_score . shape [ 0 ] == 1 , "only support batch size = 1" cls_indices = cls_indices . cpu ( ) . numpy ( ) # seg_energy: STUFF classes only seg_stuff_energy = seg_score [ [ 0 ] , : self . num_stuff_classes , : , : ] # ONLY STUFF CLASSES (11) boxes = boxes . cpu ( ) . numpy ( ) boxes = boxes [ : , 1 : ] * self . box_scale if cls_indices . size == 0 : return seg_energy , torch . ones_like ( seg_energy [ [ 0 ] , [ 0 ] , : , : ] ) . view ( 1 , 1 , seg_energy . shape [ 2 ] , seg_energy . shape [ 3 ] ) * - 10 else : seg_inst_energy = torch . zeros ( ( seg_score . shape [ 0 ] , cls_indices . shape [ 0 ] , seg_score . shape [ 2 ] , seg_score . shape [ 3 ] ) , device = seg_score . device ) for i in range ( cls_indices . shape [ 0 ] ) : if cls_indices [ i ] == 0 : continue y0 = int ( boxes [ i ] [ 1 ] ) y1 = int ( boxes [ i ] [ 3 ] . round ( ) + 1 ) x0 = int ( boxes [ i ] [ 0 ] ) x1 = int ( boxes [ i ] [ 2 ] . round ( ) + 1 ) seg_inst_energy [ 0 , i , y0 : y1 , x0 : x1 ] = seg_score [ 0 , self . class_mapping [ cls_indices [ i ] ] , y0 : y1 , x0 : x1 ] return seg_stuff_energy , seg_inst_energy