-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_create_summary_results.py
147 lines (92 loc) · 5 KB
/
main_create_summary_results.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 1 23:33:56 2023
@author: Moha-Cate
"""
import seaborn as sns
import pandas as pd
from tqdm import tqdm
sns.set_style("whitegrid")
print('################# Notice:')
print('################# Notice:')
print('################# Notice:')
print('seaborn version: ', sns.__version__)
print('if the colors in legends are mismatched, make sure to have seaborn verion 0.11.0')
print('################# Notice end')
#%% create summary dataframe for seaborn plotting
''' if you need to create summary file, uncomment this part'''
# tuples: segMethod, 'perrturbType', 'resultCSVfilename', 'originalCSVtestfile'
list_of_Results = [
('UNet++', 'orig', '../results/unetpp/orig/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_orig.csv'),
('UNet++', 'd1', '../results/unetpp/d1/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_d1.csv'),
('UNet++', 'd2', '../results/unetpp/d2/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_d2.csv'),
('DeepLabV3+', 'orig', '../results/deeplabv3plus/orig/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_orig.csv'),
('DeepLabV3+', 'd1', '../results/deeplabv3plus/d1/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_d1.csv'),
('DeepLabV3+', 'd2', '../results/deeplabv3plus/d2/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_d2.csv'),
('CE-Net', 'orig', '../results/cenet/orig/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_orig.csv'),
('CE-Net', 'd1', '../results/cenet/d1/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_d1.csv'),
('CE-Net', 'd2', '../results/cenet/d2/individual_results.csv',
'../ObservedDomain_Sritan/data_AroundDisc_256_seg_joint_test_d2.csv'),
]
df0 = pd.read_csv(list_of_Results[1][2] )
columns = df0.columns.to_list()
columns.append('Segmentation Model')
columns.append('Perturbation Type')
columns.append('Severity')
columns.append('InDomain')
columns.append('OutDomain')
df_summary = pd.DataFrame(columns=columns, ) #index=range(4*31000)
counter_index=-1
for csvtuples in list_of_Results:
#csvtuples = list_of_Results[4]
df_result = pd.read_csv(csvtuples[2] )
df_source_test = pd.read_csv(csvtuples[3] )
try:
df_source_test= df_source_test.drop(columns='index')
except:
s=1
df_result[ ['path','imageID'] ] = df_result['FullFileName'].str.split('images', expand=True)
df_result.imageID = df_result.imageID.str[1:]
df_result_merged = df_result.merge(df_source_test, how='outer', on='imageID')
if 'RIGA' in csvtuples[1]:
try:
df_result_merged = df_result_merged.loc[df_result_merged.Unet_TrainedOver!='RIGA']
except:
s=1
columns_result = df_result_merged.columns
for IND in tqdm(df_result_merged.index):
counter_index = counter_index+1
df_summary.loc[counter_index, 'Segmentation Model'] = csvtuples[0]
try:
df_summary.loc[counter_index, 'Perturbation Type'] = df_result_merged.perturb_type[IND]
except:
df_summary.loc[counter_index, 'Perturbation Type'] = 'N/A'
try:
df_summary.loc[counter_index, 'Severity'] = df_result_merged.severity[IND]
except:
df_summary.loc[counter_index, 'Severity'] = 0
# df_summary.loc[counter_index, 'Severity'] = csvtuples[0]
for col in columns_result:
df_summary.loc[counter_index, col] = df_result_merged.loc[IND, col]
if 'RIGA' in csvtuples[1]:
if 'MESSIDOR' in df_result_merged.loc[IND, 'imageID'] :
df_summary.loc[counter_index, 'InDomain'] = 1
df_summary.loc[counter_index, 'OutDomain'] = 0
else:
df_summary.loc[counter_index, 'InDomain'] = 0
df_summary.loc[counter_index, 'OutDomain'] = 1
else:
df_summary.loc[counter_index, 'InDomain'] = 1
df_summary.loc[counter_index, 'OutDomain'] = 0
df_summary.to_csv('csv_results_summary.csv', index=False)
# df_summary_ = df_summary.dropna()
# df_summary_.to_csv('csv_results_summary_2.csv', index=False)
#%%