forked from IsabelaBB/superpixel-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheval_stability.py
52 lines (36 loc) · 1.98 KB
/
eval_stability.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 argparse
import pandas as pd
import os.path
#parser = argparse.ArgumentParser()
#parser.add_argument('--input',help='The path of the source image')
#parser.add_argument('--output', help='The path of the labeled image')
DATASETS = ['Sky']
METHODS = ['CRS', 'DAL-HERS', 'DISF', 'DRW', 'ERGC', 'ERS', 'ETPS', 'GMMSP', 'GRID', 'IBIS', 'ISF', 'LNSNet', 'LSC', 'ODISF', 'RSS', 'SCALP', 'SEEDS', 'SH', 'SLIC','SNIC', 'SICLE']
METRICS = ['BR', 'UE', 'EV', 'SIRS']
SPXS = [200]
OUTPUT_PATH="../../RESULTS/Eval"
INUT_PATH="../../RESULTS/Eval"
data = {}
for dataset in DATASETS:
for method in METHODS:
for metric in METRICS:
# get min / max / dp / avg
data_spx, data_min, data_max, data_std = [], [], [], []
for num_superpixel in SPXS:
input_file = INUT_PATH + '/' +method+'/'+dataset+'/'+metric+'/'+method+'-'+num_superpixel+'.txt'
data_imgs = pd.read_csv(input_file, sep=" ", names=["Image", "Superpixels", metric])
data_spx.append(data_imgs["Superpixels"].mean())
data_min.append(data_imgs[metric].min())
data_std.append(data_imgs[metric].std())
data_max.append(data_imgs[metric].max())
key=metric+'-'+dataset+'-'+method+'-'
data[key+'MIN'] = pd.DataFrame(data={'Superpixels':data_spx, metric:data_min})
data[key+'MAX'] = pd.DataFrame(data={'Superpixels':data_spx, metric:data_max})
data[key+'STD'] = pd.DataFrame(data={'Superpixels':data_spx, metric:data_std})
for type in ['MIN', 'MAX', 'STD']:
output_file = OUTPUT_PATH + '/' +method+'/'+dataset+'/stability/'+ type
if not os.path.exists(output_file):
os.makedirs(output_file)
output_file = output_file+'/'+method+'-'+dataset+'-'+metric+'.txt'
key=metric+'-'+dataset+'-'+method+'-'+type
data[key].to_csv(output_file, header=[metric, type], index=None, sep=' ', mode='w')