-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathevaluation.py
52 lines (46 loc) · 1.6 KB
/
evaluation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import cv2
from tqdm import tqdm
import sod_metrics as M
FM = M.Fmeasure()
WFM = M.WeightedFmeasure()
SM = M.Smeasure()
EM = M.Emeasure()
MAE = M.MAE()
mask_root = '../RGBT_dataset/test/VT1000/GT'
pred_root = './output/vt1000-MAE-tha_gwm_pgfm_20p/'
mask_name_list = sorted(os.listdir(mask_root))
for mask_name in tqdm(mask_name_list, total=len(mask_name_list)):
mask_path = os.path.join(mask_root, mask_name)
pred_path = os.path.join(pred_root, mask_name)
mask = cv2.imread(mask_path, cv2.IMREAD_GRAYSCALE)
pred = cv2.imread(pred_path, cv2.IMREAD_GRAYSCALE)
FM.step(pred=pred, gt=mask)
WFM.step(pred=pred, gt=mask)
SM.step(pred=pred, gt=mask)
EM.step(pred=pred, gt=mask)
MAE.step(pred=pred, gt=mask)
fm = FM.get_results()['fm']
wfm = WFM.get_results()['wfm']
sm = SM.get_results()['sm']
em = EM.get_results()['em']
mae = MAE.get_results()['mae']
print(
'Smeasure:', sm.round(3), '; ',
'wFmeasure:', wfm.round(3), '; ',
'MAE:', mae.round(3), '; ',
'adpEm:', em['adp'].round(3), '; ',
'meanEm:', '-' if em['curve'] is None else em['curve'].mean().round(3), '; ',
'maxEm:', '-' if em['curve'] is None else em['curve'].max().round(3), '; ',
'adpFm:', fm['adp'].round(3), '; ',
'meanFm:', fm['curve'].mean().round(3), '; ',
'maxFm:', fm['curve'].max().round(3),
sep=''
)
with open("../result.txt", "a+") as f:
print('Smeasure:', sm.round(3), '; ',
'meanEm:', '-' if em['curve'] is None else em['curve'].mean().round(3), '; ',
'wFmeasure:', wfm.round(3), '; ',
'MAE:', mae.round(3), '; ',
file=f
)