lib/dataset/deepv.py
def _py_evaluate_segmentation(self):
        """
        This function is a wrapper to calculte the metrics for given pred_segmentation results
        :param pred_segmentations: the pred segmentation result
        :return: the evaluation metrics
        """
        confusion_matrix = np.zeros((self.num_classes,self.num_classes))
        result_dir = os.path.join(self.result_path, 'results', 'deepv', 'Segmentation')

        for i, index in enumerate(self.image_set_index):
            seg_gt_info = self.load_pascal_segmentation_annotation(index)
            seg_gt_path = seg_gt_info['seg_cls_path']
            seg_gt = np.array(PIL.Image.open(seg_gt_path)).astype('float32')
            seg_pred_path = os.path.join(result_dir, '%s.png'%(index))
            seg_pred = np.array(PIL.Image.open(seg_pred_path)).astype('float32')

            seg_gt = cv2.resize(seg_gt, (seg_pred.shape[1], seg_pred.shape[0]), interpolation=cv2.INTER_NEAREST)
            ignore_index = seg_gt != 255
            seg_gt = seg_gt[ignore_index]
            seg_pred = seg_pred[ignore_index]

            confusion_matrix += self.get_confusion_matrix(seg_gt, seg_pred, self.num_classes)

        pos = confusion_matrix.sum(1)
        res = confusion_matrix.sum(0)
        tp = np.diag(confusion_matrix)

        IU_array = (tp / np.maximum(1.0, pos + res - tp))
        mean_IU = IU_array.mean()

        return {'meanIU':mean_IU, 'IU_array':IU_array}

        This function is a wrapper to calculte the metrics for given pred_segmentation results
        :param pred_segmentations: the pred segmentation result
        :return: the evaluation metrics
        
This function is a wrapper to calculte the metrics for given pred_segmentation results
This function is a wrapper to calculte the metrics for given pred_segmentation results
def _py_evaluate_segmentation(self):
        confusion_matrix = np.zeros((self.num_classes,self.num_classes))
        result_dir = os.path.join(self.result_path, 'results', 'deepv', 'Segmentation')
        for i, index in enumerate(self.image_set_index):
            seg_gt_info = self.load_pascal_segmentation_annotation(index)
            seg_gt_path = seg_gt_info['seg_cls_path']
            seg_gt = np.array(PIL.Image.open(seg_gt_path)).astype('float32')
            seg_pred_path = os.path.join(result_dir, '%s.png'%(index))
            seg_pred = np.array(PIL.Image.open(seg_pred_path)).astype('float32')
            seg_gt = cv2.resize(seg_gt, (seg_pred.shape[1], seg_pred.shape[0]), interpolation=cv2.INTER_NEAREST)
            ignore_index = seg_gt != 255
            seg_gt = seg_gt[ignore_index]
            seg_pred = seg_pred[ignore_index]
            confusion_matrix += self.get_confusion_matrix(seg_gt, seg_pred, self.num_classes)
        pos = confusion_matrix.sum(1)
        res = confusion_matrix.sum(0)
        tp = np.diag(confusion_matrix)
        IU_array = (tp / np.maximum(1.0, pos + res - tp))
        mean_IU = IU_array.mean()
        return {'meanIU':mean_IU, 'IU_array':IU_array}
def _py_evaluate_segmentation ( self ) : confusion_matrix = np . zeros ( ( self . num_classes , self . num_classes ) ) result_dir = os . path . join ( self . result_path , 'results' , 'deepv' , 'Segmentation' ) for i , index in enumerate ( self . image_set_index ) : seg_gt_info = self . load_pascal_segmentation_annotation ( index ) seg_gt_path = seg_gt_info [ 'seg_cls_path' ] seg_gt = np . array ( PIL . Image . open ( seg_gt_path ) ) . astype ( 'float32' ) seg_pred_path = os . path . join ( result_dir , '%s.png' % ( index ) ) seg_pred = np . array ( PIL . Image . open ( seg_pred_path ) ) . astype ( 'float32' ) seg_gt = cv2 . resize ( seg_gt , ( seg_pred . shape [ 1 ] , seg_pred . shape [ 0 ] ) , interpolation = cv2 . INTER_NEAREST ) ignore_index = seg_gt != 255 seg_gt = seg_gt [ ignore_index ] seg_pred = seg_pred [ ignore_index ] confusion_matrix += self . get_confusion_matrix ( seg_gt , seg_pred , self . num_classes ) pos = confusion_matrix . sum ( 1 ) res = confusion_matrix . sum ( 0 ) tp = np . diag ( confusion_matrix ) IU_array = ( tp / np . maximum ( 1.0 , pos + res - tp ) ) mean_IU = IU_array . mean ( ) return { 'meanIU' : mean_IU , 'IU_array' : IU_array }
This function is a wrapper to calculte the metrics for given pred_segmentation results
This function is a wrapper to calculte the metrics for given pred_segmentation results
"""
        This function is a wrapper to calculte the metrics for given pred_segmentation results
        :param pred_segmentations: the pred segmentation result
        :return: the evaluation metrics
        """
the evaluation metrics
the evaluation metrics
self
pred_segmentations
the pred segmentation result
the pred segmentation result