@@ -65,11 +65,16 @@ def generate_proposals(opt, video_list, video_data):
65
65
print ('Skipping %s because %s is not a path.' % (video_name , results_path ))
66
66
skipped_paths .append (results_path )
67
67
continue
68
+
69
+ anno_df_ = anno_df [anno_df .video == video_name ]
68
70
69
71
tdf = pd .read_csv (results_path )
70
72
start_scores = tdf .start .values [:]
71
73
end_scores = tdf .end .values [:]
72
- frame_list = tdf .frames .values [:]
74
+ try :
75
+ frame_list = tdf .frames .values [:]
76
+ except Exception as e :
77
+ frame_list = tdf .frame .values [:]
73
78
74
79
start_bins = np .zeros (len (start_scores ))
75
80
start_bins [[0 , - 1 ]] = 1
@@ -95,15 +100,14 @@ def generate_proposals(opt, video_list, video_data):
95
100
xmin_score_list = []
96
101
xmax_list = []
97
102
xmax_score_list = []
98
- for index in range (len (start_bins )):
103
+ for index in range (len (start_scores )):
99
104
if start_bins [index ] == 1 :
100
105
xmin_list .append (int (frame_list [index ]))
101
106
xmin_score_list .append (start_scores [index ])
102
107
if end_bins [index ] == 1 :
103
108
xmax_list .append (int (frame_list [index ]))
104
109
xmax_score_list .append (end_scores [index ])
105
110
106
- print ('Doing new_props' )
107
111
new_props = []
108
112
for ii in range (len (xmax_list )):
109
113
if ii % 5000 == 0 :
@@ -133,7 +137,6 @@ def generate_proposals(opt, video_list, video_data):
133
137
# print('saving preliminary to %s' % path)
134
138
# new_df.to_csv(path, index=False)
135
139
136
- print ('Doing gt max' )
137
140
if video_dict is not None :
138
141
video_info = video_dict [video_name ]
139
142
video_fps = video_info ['fps' ]
@@ -146,25 +149,29 @@ def generate_proposals(opt, video_list, video_data):
146
149
147
150
gt_xmins .append (annos [idx ]["segment" ][0 ] * video_fps )
148
151
gt_xmaxs .append (annos [idx ]["segment" ][1 ] * video_fps )
149
- elif anno_df is not None :
150
- gt_xmins = anno_df .startFrame .values [:]
151
- gt_xmaxs = anno_df .endFrame .values [:]
152
-
153
- print ('GT Xmins and Xmaxs' )
152
+ elif anno_df_ is not None :
153
+ gt_xmins = anno_df_ .startFrame .values [:]
154
+ gt_xmaxs = anno_df_ .endFrame .values [:]
155
+
156
+ # Ok, so all of these gt_xmins and gt_xmaxs are the same ...
157
+ # ... As are the xmin and xmax values in the DFs.
158
+
154
159
new_iou_list = []
155
160
match_xmin_list = []
156
161
match_xmax_list = []
157
- print ('Doing iou and xmin lists.' )
158
162
for j in range (len (new_df )):
159
163
tmp_new_iou = list (
160
- iou_with_anchors (new_df .xmin .values [j ],
161
- new_df .xmax .values [j ], gt_xmins , gt_xmaxs ))
164
+ iou_with_anchors (
165
+ new_df .xmin .values [j ],
166
+ new_df .xmax .values [j ],
167
+ gt_xmins ,
168
+ gt_xmaxs )
169
+ )
162
170
new_iou_list .append (max (tmp_new_iou ))
163
171
match_xmin_list .append (gt_xmins [tmp_new_iou .index (max (tmp_new_iou ))])
164
172
match_xmax_list .append (gt_xmaxs [tmp_new_iou .index (max (tmp_new_iou ))])
165
173
166
174
new_ioa_list = []
167
- print ('Doing ioa max' )
168
175
for j in range (len (new_df )):
169
176
tmp_new_ioa = max (
170
177
ioa_with_anchors (new_df .xmin .values [j ],
@@ -179,8 +186,7 @@ def generate_proposals(opt, video_list, video_data):
179
186
print ('saving to %s' % path )
180
187
new_df .to_csv (path , index = False )
181
188
print ('Video %s took %.4f time' % (video_name , time .time () - start_time ))
182
- print ('Total time was %.4f' % (time .time () - start_time ))
183
- print (skipped_paths )
189
+ print ('Total time was %.4f' % (time .time () - start_time ), skipped_paths )
184
190
185
191
186
192
def getDatasetDict (opt ):
@@ -211,11 +217,10 @@ def bookend_zeros(arr, num):
211
217
return np .concatenate ([np .zeros ([num ]), arr , np .zeros ([num ])])
212
218
213
219
214
- def generate_features_repr (opt , video_list , video_dict ):
220
+ def generate_features (opt , video_list , video_dict ):
215
221
num_sample_start = opt ["num_sample_start" ]
216
222
num_sample_end = opt ["num_sample_end" ]
217
223
num_sample_action = opt ["num_sample_action" ]
218
- num_sample_interpld = opt ["num_sample_interpld" ]
219
224
num_videoframes = opt ["num_videoframes" ]
220
225
skip_videoframes = opt ["skip_videoframes" ]
221
226
bookend_num = int (num_videoframes / skip_videoframes )
@@ -234,6 +239,10 @@ def generate_features_repr(opt, video_list, video_dict):
234
239
print ("NOT generating features for %s because features don't exist." % video_name )
235
240
continue
236
241
adf = pd .read_csv (tem_path )
242
+ try :
243
+ adf_frames = adf .frames .values [:]
244
+ except Exception as e :
245
+ adf_frames = adf .frame .values [:]
237
246
238
247
proposals_path = os .path .join (proposals_dir , '%s.proposals.csv' % video_name )
239
248
if not os .path .exists (proposals_path ):
@@ -247,7 +256,7 @@ def generate_features_repr(opt, video_list, video_dict):
247
256
score_end = bookend_zeros (adf .end .values [:], bookend_num )
248
257
score_start = bookend_zeros (adf .start .values [:], bookend_num )
249
258
#
250
- snippets = [skip_videoframes * i - normalizer for i in range (bookend_num )] + list (adf . frames . values [:] ) + [skip_videoframes * i + skip_videoframes + adf . frames . values [:] [- 1 ] for i in range (bookend_num )]
259
+ snippets = [skip_videoframes * i - normalizer for i in range (bookend_num )] + list (adf_frames ) + [skip_videoframes * i + skip_videoframes + adf_frames [- 1 ] for i in range (bookend_num )]
251
260
print ('Computing the interp1ds' )
252
261
f_action = interp1d (snippets , score_action , axis = 0 )
253
262
f_start = interp1d (snippets , score_start , axis = 0 )
@@ -282,7 +291,11 @@ def generate_features_repr(opt, video_list, video_dict):
282
291
283
292
#action
284
293
plen_action = (xmax - xmin ) / (num_sample_action - 1 )
285
- tmp_x_new = [xmin_0 + plen_action * ii for ii in range (num_sample_action )]
294
+
295
+ # I originall had the following (see xmin_0)
296
+ # tmp_x_new = [xmin_0 + plen_action * ii for ii in range(num_sample_action)]
297
+ # But they have this:
298
+ tmp_x_new = [xmin + plen_action * ii for ii in range (num_sample_action )]
286
299
tmp_y_new_action = f_action (tmp_x_new )
287
300
tmp_y_new_action = np .reshape (tmp_y_new_action , [- 1 ])
288
301
@@ -303,6 +316,8 @@ def PGM_proposal_generation(opt):
303
316
if 'thumos' in opt ['dataset' ]:
304
317
video_data = pd .read_csv (os .path .join (opt ["video_info" ], 'Full_Annotation.csv' ))
305
318
video_list = sorted (list (set (video_data .video .values [:])))
319
+ # video_list = [k for k in video_list if 'video_validation_0000053' in k]
320
+ # print(video_list)
306
321
else :
307
322
video_data = load_json (opt ["video_anno" ])
308
323
video_list = sorted (video_data .keys ()) #[:199]
@@ -348,7 +363,7 @@ def PGM_feature_generation(opt):
348
363
# NOTE: change this back.
349
364
# video_list = [k for k in video_list if '12.18.18' in k or '12.5.18' in k]
350
365
351
- func = generate_features_repr
366
+ func = generate_features
352
367
num_videos = len (video_list )
353
368
num_threads = min (num_videos , opt ['pgm_thread' ])
354
369
num_videos_per_thread = int (num_videos / opt ["pgm_thread" ])
0 commit comments