-
Notifications
You must be signed in to change notification settings - Fork 0
/
merging_csvs.py
266 lines (244 loc) · 15.1 KB
/
merging_csvs.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
import pandas as pd
csv_path = {
'conditioned':{
'videocon_synth':{
'r1': 'data/entailment/final_videocon_s001_conditioned_synth-synth_scores.csv',
'r2': 'data/entailment/final_videocon_s002_conditioned_synth-synth_scores.csv',
'r3': 'data/entailment/final_videocon_s003_conditioned_synth-synth_scores.csv',
'r4': 'data/entailment/final_videocon_s004_conditioned_synth-synth_scores.csv',
'r5': 'data/entailment/final_videocon_s005_conditioned_synth-synth_scores.csv'},
'videocon_real':{
'r1': 'data/entailment/final_videocon_s001_conditioned_synth-real_scores.csv',
'r2': 'data/entailment/final_videocon_s002_conditioned_synth-real_scores.csv',
'r3': 'data/entailment/final_videocon_s003_conditioned_synth-real_scores.csv',
'r4': 'data/entailment/final_videocon_s004_conditioned_synth-real_scores.csv',
'r5': 'data/entailment/final_videocon_s005_conditioned_synth-real_scores.csv'},
'clip_flant':{
'r1': 'data/entailment/videocon_s001_conditioned_clip-flant5-xxl_sample_4_frame.csv',
'r2': 'data/entailment/videocon_s002_conditioned_clip-flant5-xxl_sample_4_frame.csv',
'r3': 'data/entailment/videocon_s003_conditioned_clip-flant5-xxl_sample_4_frame.csv',
'r4': 'data/entailment/videocon_s004_conditioned_clip-flant5-xxl_sample_4_frame.csv',
'r5': 'data/entailment/videocon_s005_conditioned_clip-flant5-xxl_sample_4_frame.csv'},
'instructblip_flant':{
'r1': 'data/entailment/videocon_s001_conditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r2': 'data/entailment/videocon_s002_conditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r3': 'data/entailment/videocon_s003_conditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r4': 'data/entailment/videocon_s004_conditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r5': 'data/entailment/videocon_s005_conditioned_instructblip-flant5-xxl_sample_4_frame.csv'},
'llava':{
'r1': 'data/entailment/videocon_s001_conditioned_llava-v1.5-13b_sample_4_frame.csv',
'r2': 'data/entailment/videocon_s002_conditioned_llava-v1.5-13b_sample_4_frame.csv',
'r3': 'data/entailment/videocon_s003_conditioned_llava-v1.5-13b_sample_4_frame.csv',
'r4': 'data/entailment/videocon_s004_conditioned_llava-v1.5-13b_sample_4_frame.csv',
'r5': 'data/entailment/videocon_s005_conditioned_llava-v1.5-13b_sample_4_frame.csv'},
},
'unconditioned':{
'videocon_synth':{
'r1': 'data/entailment/final_videocon_s001_unconditioned_synth-synth_scores.csv',
'r2': 'data/entailment/final_videocon_s002_unconditioned_synth-synth_scores.csv',
'r3': 'data/entailment/final_videocon_s003_unconditioned_synth-synth_scores.csv',
'r4': 'data/entailment/final_videocon_s004_unconditioned_synth-synth_scores.csv',
'r5': 'data/entailment/final_videocon_s005_unconditioned_synth-synth_scores.csv'},
'videocon_real':{
'r1': 'data/entailment/final_videocon_s001_unconditioned_synth-real_scores.csv',
'r2': 'data/entailment/final_videocon_s002_unconditioned_synth-real_scores.csv',
'r3': 'data/entailment/final_videocon_s003_unconditioned_synth-real_scores.csv',
'r4': 'data/entailment/final_videocon_s004_unconditioned_synth-real_scores.csv',
'r5': 'data/entailment/final_videocon_s005_unconditioned_synth-real_scores.csv'},
'clip_flant':{
'r1': 'data/entailment/videocon_s001_unconditioned_clip-flant5-xxl_sample_4_frame.csv',
'r2': 'data/entailment/videocon_s002_unconditioned_clip-flant5-xxl_sample_4_frame.csv',
'r3': 'data/entailment/videocon_s003_unconditioned_clip-flant5-xxl_sample_4_frame.csv',
'r4': 'data/entailment/videocon_s004_unconditioned_clip-flant5-xxl_sample_4_frame.csv',
'r5': 'data/entailment/videocon_s005_unconditioned_clip-flant5-xxl_sample_4_frame.csv'},
'instructblip_flant':{
'r1': 'data/entailment/videocon_s001_unconditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r2': 'data/entailment/videocon_s002_unconditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r3': 'data/entailment/videocon_s003_unconditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r4': 'data/entailment/videocon_s004_unconditioned_instructblip-flant5-xxl_sample_4_frame.csv',
'r5': 'data/entailment/videocon_s005_unconditioned_instructblip-flant5-xxl_sample_4_frame.csv'},
'llava':{
'r1': 'data/entailment/videocon_s001_unconditioned_llava-v1.5-13b_sample_4_frame.csv',
'r2': 'data/entailment/videocon_s002_unconditioned_llava-v1.5-13b_sample_4_frame.csv',
'r3': 'data/entailment/videocon_s003_unconditioned_llava-v1.5-13b_sample_4_frame.csv',
'r4': 'data/entailment/videocon_s004_unconditioned_llava-v1.5-13b_sample_4_frame.csv',
'r5': 'data/entailment/videocon_s005_unconditioned_llava-v1.5-13b_sample_4_frame.csv'},
}
}
csv_scores = {
'conditioned': {
'videocon_synth': [
pd.read_csv(csv_path['conditioned']['videocon_synth']['r1']),
pd.read_csv(csv_path['conditioned']['videocon_synth']['r2']),
pd.read_csv(csv_path['conditioned']['videocon_synth']['r3']),
pd.read_csv(csv_path['conditioned']['videocon_synth']['r4']),
pd.read_csv(csv_path['conditioned']['videocon_synth']['r5'])],
'videocon_real': [
pd.read_csv(csv_path['conditioned']['videocon_real']['r1']),
pd.read_csv(csv_path['conditioned']['videocon_real']['r2']),
pd.read_csv(csv_path['conditioned']['videocon_real']['r3']),
pd.read_csv(csv_path['conditioned']['videocon_real']['r4']),
pd.read_csv(csv_path['conditioned']['videocon_real']['r5'])],
'clip_flant': [
pd.read_csv(csv_path['conditioned']['clip_flant']['r1']),
pd.read_csv(csv_path['conditioned']['clip_flant']['r2']),
pd.read_csv(csv_path['conditioned']['clip_flant']['r3']),
pd.read_csv(csv_path['conditioned']['clip_flant']['r4']),
pd.read_csv(csv_path['conditioned']['clip_flant']['r5'])],
'instructblip_flant': [
pd.read_csv(csv_path['conditioned']['instructblip_flant']['r1']),
pd.read_csv(csv_path['conditioned']['instructblip_flant']['r2']),
pd.read_csv(csv_path['conditioned']['instructblip_flant']['r3']),
pd.read_csv(csv_path['conditioned']['instructblip_flant']['r4']),
pd.read_csv(csv_path['conditioned']['instructblip_flant']['r5'])],
'llava': [
pd.read_csv(csv_path['conditioned']['llava']['r1']),
pd.read_csv(csv_path['conditioned']['llava']['r2']),
pd.read_csv(csv_path['conditioned']['llava']['r3']),
pd.read_csv(csv_path['conditioned']['llava']['r4']),
pd.read_csv(csv_path['conditioned']['llava']['r5'])]
},
'unconditioned': {
'videocon_synth': [
pd.read_csv(csv_path['unconditioned']['videocon_synth']['r1']),
pd.read_csv(csv_path['unconditioned']['videocon_synth']['r2']),
pd.read_csv(csv_path['unconditioned']['videocon_synth']['r3']),
pd.read_csv(csv_path['unconditioned']['videocon_synth']['r4']),
pd.read_csv(csv_path['unconditioned']['videocon_synth']['r5'])],
'videocon_real': [
pd.read_csv(csv_path['unconditioned']['videocon_real']['r1']),
pd.read_csv(csv_path['unconditioned']['videocon_real']['r2']),
pd.read_csv(csv_path['unconditioned']['videocon_real']['r3']),
pd.read_csv(csv_path['unconditioned']['videocon_real']['r4']),
pd.read_csv(csv_path['unconditioned']['videocon_real']['r5'])],
'clip_flant': [
pd.read_csv(csv_path['unconditioned']['clip_flant']['r1']),
pd.read_csv(csv_path['unconditioned']['clip_flant']['r2']),
pd.read_csv(csv_path['unconditioned']['clip_flant']['r3']),
pd.read_csv(csv_path['unconditioned']['clip_flant']['r4']),
pd.read_csv(csv_path['unconditioned']['clip_flant']['r5'])],
'instructblip_flant': [
pd.read_csv(csv_path['unconditioned']['instructblip_flant']['r1']),
pd.read_csv(csv_path['unconditioned']['instructblip_flant']['r2']),
pd.read_csv(csv_path['unconditioned']['instructblip_flant']['r3']),
pd.read_csv(csv_path['unconditioned']['instructblip_flant']['r4']),
pd.read_csv(csv_path['unconditioned']['instructblip_flant']['r5'])],
'llava': [
pd.read_csv(csv_path['unconditioned']['llava']['r1']),
pd.read_csv(csv_path['unconditioned']['llava']['r2']),
pd.read_csv(csv_path['unconditioned']['llava']['r3']),
pd.read_csv(csv_path['unconditioned']['llava']['r4']),
pd.read_csv(csv_path['unconditioned']['llava']['r5'])]
}
}
dataset = pd.read_csv('data/my_new_dataset.csv')
dataset[f'videocon_synth conditioned r1 ent'] = 0
dataset[f'videocon_synth conditioned r2 ent'] = 0
dataset[f'videocon_synth conditioned r3 ent'] = 0
dataset[f'videocon_synth conditioned r4 ent'] = 0
dataset[f'videocon_synth conditioned r5 ent'] = 0
dataset[f'videocon_synth unconditioned r1 ent'] = 0
dataset[f'videocon_synth unconditioned r2 ent'] = 0
dataset[f'videocon_synth unconditioned r3 ent'] = 0
dataset[f'videocon_synth unconditioned r4 ent'] = 0
dataset[f'videocon_synth unconditioned r5 ent'] = 0
dataset[f'videocon_real conditioned r1 ent'] = 0
dataset[f'videocon_real conditioned r2 ent'] = 0
dataset[f'videocon_real conditioned r3 ent'] = 0
dataset[f'videocon_real conditioned r4 ent'] = 0
dataset[f'videocon_real conditioned r5 ent'] = 0
dataset[f'videocon_real unconditioned r1 ent'] = 0
dataset[f'videocon_real unconditioned r2 ent'] = 0
dataset[f'videocon_real unconditioned r3 ent'] = 0
dataset[f'videocon_real unconditioned r4 ent'] = 0
dataset[f'videocon_real unconditioned r5 ent'] = 0
dataset[f'clip_flant synth conditioned r1 ent'] = 0
dataset[f'clip_flant synth conditioned r2 ent'] = 0
dataset[f'clip_flant synth conditioned r3 ent'] = 0
dataset[f'clip_flant synth conditioned r4 ent'] = 0
dataset[f'clip_flant synth conditioned r5 ent'] = 0
dataset[f'clip_flant synth unconditioned r1 ent'] = 0
dataset[f'clip_flant synth unconditioned r2 ent'] = 0
dataset[f'clip_flant synth unconditioned r3 ent'] = 0
dataset[f'clip_flant synth unconditioned r4 ent'] = 0
dataset[f'clip_flant synth unconditioned r5 ent'] = 0
dataset[f'clip_flant real conditioned r1 ent'] = 0
dataset[f'clip_flant real conditioned r2 ent'] = 0
dataset[f'clip_flant real conditioned r3 ent'] = 0
dataset[f'clip_flant real conditioned r4 ent'] = 0
dataset[f'clip_flant real conditioned r5 ent'] = 0
dataset[f'clip_flant real unconditioned r1 ent'] = 0
dataset[f'clip_flant real unconditioned r2 ent'] = 0
dataset[f'clip_flant real unconditioned r3 ent'] = 0
dataset[f'clip_flant real unconditioned r4 ent'] = 0
dataset[f'clip_flant real unconditioned r5 ent'] = 0
dataset[f'instructblip_flant synth conditioned r1 ent'] = 0
dataset[f'instructblip_flant synth conditioned r2 ent'] = 0
dataset[f'instructblip_flant synth conditioned r3 ent'] = 0
dataset[f'instructblip_flant synth conditioned r4 ent'] = 0
dataset[f'instructblip_flant synth conditioned r5 ent'] = 0
dataset[f'instructblip_flant synth unconditioned r1 ent'] = 0
dataset[f'instructblip_flant synth unconditioned r2 ent'] = 0
dataset[f'instructblip_flant synth unconditioned r3 ent'] = 0
dataset[f'instructblip_flant synth unconditioned r4 ent'] = 0
dataset[f'instructblip_flant synth unconditioned r5 ent'] = 0
dataset[f'instructblip_flant real conditioned r1 ent'] = 0
dataset[f'instructblip_flant real conditioned r2 ent'] = 0
dataset[f'instructblip_flant real conditioned r3 ent'] = 0
dataset[f'instructblip_flant real conditioned r4 ent'] = 0
dataset[f'instructblip_flant real conditioned r5 ent'] = 0
dataset[f'instructblip_flant real unconditioned r1 ent'] = 0
dataset[f'instructblip_flant real unconditioned r2 ent'] = 0
dataset[f'instructblip_flant real unconditioned r3 ent'] = 0
dataset[f'instructblip_flant real unconditioned r4 ent'] = 0
dataset[f'instructblip_flant real unconditioned r5 ent'] = 0
dataset[f'llava synth conditioned r1 ent'] = 0
dataset[f'llava synth conditioned r2 ent'] = 0
dataset[f'llava synth conditioned r3 ent'] = 0
dataset[f'llava synth conditioned r4 ent'] = 0
dataset[f'llava synth conditioned r5 ent'] = 0
dataset[f'llava synth unconditioned r1 ent'] = 0
dataset[f'llava synth unconditioned r2 ent'] = 0
dataset[f'llava synth unconditioned r3 ent'] = 0
dataset[f'llava synth unconditioned r4 ent'] = 0
dataset[f'llava synth unconditioned r5 ent'] = 0
dataset[f'llava real conditioned r1 ent'] = 0
dataset[f'llava real conditioned r2 ent'] = 0
dataset[f'llava real conditioned r3 ent'] = 0
dataset[f'llava real conditioned r4 ent'] = 0
dataset[f'llava real conditioned r5 ent'] = 0
dataset[f'llava real unconditioned r1 ent'] = 0
dataset[f'llava real unconditioned r2 ent'] = 0
dataset[f'llava real unconditioned r3 ent'] = 0
dataset[f'llava real unconditioned r4 ent'] = 0
dataset[f'llava real unconditioned r5 ent'] = 0
for type in csv_scores:
for set in csv_scores[type]:
j = 0
for round in csv_scores[type][set]:
j += 1
for index,row in dataset.iterrows():
if set == 'videocon_synth':
synth_cap_entail = round.loc[(round['videopath'] == row.videopath) & (round['text'] == row.neg_caption)]['entailment'].values
if len(synth_cap_entail) != 0:
dataset[f'{set} {type} r{j} ent'].at[index] = synth_cap_entail[0]
else:
dataset[f'{set} {type} r{j} ent'].at[index] = -1
elif set == 'videocon_real':
real_cap_entail = round.loc[(round['videopath'] == row.videopath) & (round['text'] == row.caption)]['entailment'].values
if len(real_cap_entail) != 0:
dataset[f'{set} {type} r{j} ent'].at[index] = real_cap_entail[0]
else:
dataset[f'{set} {type} r{j} ent'].at[index] = -1
else:
synth_caption_entail = round.loc[(round['videopath'] == row.videopath) & (round['text'] == row.neg_caption)]['entailment'].values
real_caption_entail = round.loc[(round['videopath'] == row.videopath) & (round['text'] == row.caption)]['entailment'].values
if len(synth_caption_entail) != 0:
dataset[f'{set} synth {type} r{j} ent'].at[index] = synth_caption_entail[0]
else:
dataset[f'{set} synth {type} r{j} ent'].at[index] = -1
if len(real_caption_entail) != 0:
dataset[f'{set} real {type} r{j} ent'].at[index] = real_caption_entail[0]
else:
dataset[f'{set} real {type} r{j} ent'].at[index] = -1
dataset.to_csv('final_dataset.csv', index=False)