def eval_segment_with_annot(params, dict_annot, dict_segm, dict_label_hist=None, name_csv=NAME_CSV_SEGM_STAT_SLIC_ANNOT, nb_jobs=1): """ evaluate the segmentation results according given annotation :param {str: ...} params: :param {str: ndarray} dict_annot: :param {str: ndarray} dict_segm: :param {str: ndarray} dict_label_hist: :param str name_csv: :param int nb_jobs: :return: """ if dict_label_hist is not None: visu_histogram_labels(params, dict_label_hist) assert sorted(dict_annot.keys()) == sorted(dict_segm.keys()), \ 'mismatch in dictionary keys: \n%s \n%s' % (sorted(dict_annot.keys()), sorted(dict_segm.keys())) list_annot = [dict_annot[n] for n in dict_annot] list_segm = [dict_segm[n] for n in dict_annot] df_stat = seg_clf.compute_stat_per_image(list_segm, list_annot, [n for n in dict_annot], nb_jobs) path_csv = os.path.join(params['path_exp'], name_csv) logging.info('STAT on seg_pipe and annot (%s):', name_csv) df_stat.to_csv(path_csv) logging.info(metrics.classification_report( seg_label.convert_segms_2_list(list_segm), seg_label.convert_segms_2_list(list_annot), digits=4)) logging.debug(repr(df_stat)) return df_stat
def eval_segment_with_annot( params, dict_annot, dict_segm, dict_label_hist=None, name_csv='statistic___.csv', drop_labels=None, nb_workers=1, ): """ evaluate the segmentation results according given annotation :param dict params: :param {str: ndarray} dict_annot: :param {str: ndarray} dict_segm: :param {str: ndarray} dict_label_hist: :param str name_csv: :param int nb_workers: :return: """ if dict_label_hist is not None: visu_histogram_labels(params, dict_label_hist) if sorted(dict_annot) != sorted(dict_segm): raise ValueError('mismatch in dictionary keys: \n%s \n%s' % (sorted(dict_annot.keys()), sorted(dict_segm.keys()))) list_annot = [dict_annot[n] for n in dict_annot] list_segm = [dict_segm[n] for n in dict_annot] df_stat = seg_clf.compute_stat_per_image(list_segm, list_annot, list(dict_annot), nb_workers, drop_labels=drop_labels) path_csv = os.path.join(params['path_exp'], name_csv) logging.info('STATISTIC on segm and annot (%s):', name_csv) df_stat.to_csv(path_csv) logging.info( metrics.classification_report( seg_label.convert_segms_2_list(list_segm), seg_label.convert_segms_2_list(list_annot), digits=4)) logging.debug('%r', df_stat) return df_stat