Skip to content

Commit

Permalink
add feature mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshohara committed Sep 25, 2017
1 parent f27d537 commit 2eb793c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from temporal_transforms import LoopPadding

def classify_video(video_dir, video_name, class_names, model, opt):
assert opt.mode in ['score', 'feature']

spatial_transform = Compose([Scale(opt.sample_size),
CenterCrop(opt.sample_size),
ToTensor(),
Expand Down Expand Up @@ -37,9 +39,14 @@ def classify_video(video_dir, video_name, class_names, model, opt):
for i in range(video_outputs.size(0)):
clip_results = {
'segment': video_segments[i].tolist(),
'label': class_names[max_indices[i]],
'scores': video_outputs[i].tolist()
}

if opt.mode == 'score':
clip_results['label'] = class_names[max_indices[i]]
clip_results['scores'] = video_outputs[i].tolist()
elif opt.mode == 'feature':
clip_results['features'] = video_outputs[i].tolist()

results['clips'].append(clip_results)

return results

0 comments on commit 2eb793c

Please sign in to comment.