(opt)
| 14 | |
| 15 | |
| 16 | def do_eval(opt): |
| 17 | # evaluation for whole dataset |
| 18 | # dataset first in evaluation |
| 19 | for _data_name in opt.data_lst.split('+'): |
| 20 | pred_data_dir = sorted(glob(os.path.join(opt.pred_root, opt.model_lst[0], _data_name))) |
| 21 | if not pred_data_dir: |
| 22 | print('Skip dataset {}.'.format(_data_name)) |
| 23 | continue |
| 24 | gt_src = os.path.join(opt.gt_root, _data_name) |
| 25 | gt_paths = sorted(glob(os.path.join(gt_src, 'gt', '*'))) |
| 26 | print('#' * 20, _data_name, '#' * 20) |
| 27 | filename = os.path.join(opt.save_dir, '{}_eval.txt'.format(_data_name)) |
| 28 | tb = pt.PrettyTable() |
| 29 | tb.vertical_char = '&' |
| 30 | if config.task == 'DIS5K': |
| 31 | tb.field_names = ["Dataset", "Method", "maxFm", "wFmeasure", 'MAE', "Smeasure", "meanEm", "HCE", "maxEm", "meanFm", "adpEm", "adpFm"] |
| 32 | elif config.task == 'COD': |
| 33 | tb.field_names = ["Dataset", "Method", "Smeasure", "wFmeasure", "meanFm", "maxFm", "meanEm", "maxEm", 'MAE', "adpEm", "adpFm", "HCE"] |
| 34 | elif config.task == 'HRSOD': |
| 35 | tb.field_names = ["Dataset", "Method", "Smeasure", "maxFm", "meanEm", 'MAE', "maxEm", "meanFm", "wFmeasure", "adpEm", "adpFm", "HCE"] |
| 36 | elif config.task == 'DIS5K+HRSOD+HRS10K': |
| 37 | tb.field_names = ["Dataset", "Method", "maxFm", "wFmeasure", 'MAE', "Smeasure", "meanEm", "HCE", "maxEm", "meanFm", "adpEm", "adpFm"] |
| 38 | elif config.task == 'P3M-10k': |
| 39 | tb.field_names = ["Dataset", "Method", "Smeasure", "maxFm", "meanEm", 'MAE', "maxEm", "meanFm", "wFmeasure", "adpEm", "adpFm", "HCE"] |
| 40 | else: |
| 41 | tb.field_names = ["Dataset", "Method", "Smeasure", 'MAE', "maxEm", "meanEm", "maxFm", "meanFm", "wFmeasure", "adpEm", "adpFm", "HCE"] |
| 42 | for _model_name in opt.model_lst[:]: |
| 43 | print('\t', 'Evaluating model: {}...'.format(_model_name)) |
| 44 | pred_paths = [p.replace(opt.gt_root, os.path.join(opt.pred_root, _model_name)).replace('/gt/', '/') for p in gt_paths] |
| 45 | # print(pred_paths[:1], gt_paths[:1]) |
| 46 | em, sm, fm, mae, wfm, hce = evaluator( |
| 47 | gt_paths=gt_paths, |
| 48 | pred_paths=pred_paths, |
| 49 | metrics=opt.metrics.split('+'), |
| 50 | verbose=config.verbose_eval |
| 51 | ) |
| 52 | if config.task == 'DIS5K': |
| 53 | scores = [ |
| 54 | fm['curve'].max().round(3), wfm.round(3), mae.round(3), sm.round(3), em['curve'].mean().round(3), int(hce.round()), |
| 55 | em['curve'].max().round(3), fm['curve'].mean().round(3), em['adp'].round(3), fm['adp'].round(3), |
| 56 | ] |
| 57 | elif config.task == 'COD': |
| 58 | scores = [ |
| 59 | sm.round(3), wfm.round(3), fm['curve'].mean().round(3), fm['curve'].max().round(3), em['curve'].mean().round(3), em['curve'].max().round(3), mae.round(3), |
| 60 | em['adp'].round(3), fm['adp'].round(3), int(hce.round()), |
| 61 | ] |
| 62 | elif config.task == 'HRSOD': |
| 63 | scores = [ |
| 64 | sm.round(3), fm['curve'].max().round(3), em['curve'].mean().round(3), mae.round(3), |
| 65 | em['curve'].max().round(3), fm['curve'].mean().round(3), wfm.round(3), em['adp'].round(3), fm['adp'].round(3), int(hce.round()), |
| 66 | ] |
| 67 | elif config.task == 'DIS5K+HRSOD+HRS10K': |
| 68 | scores = [ |
| 69 | fm['curve'].max().round(3), wfm.round(3), mae.round(3), sm.round(3), em['curve'].mean().round(3), int(hce.round()), |
| 70 | em['curve'].max().round(3), fm['curve'].mean().round(3), em['adp'].round(3), fm['adp'].round(3), |
| 71 | ] |
| 72 | elif config.task == 'P3M-10k': |
| 73 | scores = [ |
no test coverage detected