Skip to content

Commit 5e0e547

Browse files
committed
added hmdb repro
1 parent 570f60d commit 5e0e547

File tree

14 files changed

+8712
-69
lines changed

14 files changed

+8712
-69
lines changed

repro/hollywood-2/dot_kernel.py renamed to repro/dot_kernel.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#! /usr/bin/env python
22

3+
import os
34
import sys
45
import itertools
56
import numpy as np
67
import numpy.linalg as linalg
78

8-
IN = sys.argv[1:]
9+
IN = [os.path.join(sys.argv[1], x[:-1] + '.txt') for x in open(sys.argv[2])]
910

1011
skipComments = lambda path: itertools.ifilter(lambda x: not x.startswith('#'), open(path))
1112
ks = [None]*len(list(skipComments(IN[0])))

repro/hmdb-51/Makefile

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Parameter settings
2+
FV_GMM_NCOMPONENTS = 256
3+
FASTFV_KNN = 5
4+
5+
# uncomment next three lines to enable flann
6+
#FASTFV_FLANN_NTREES = 4
7+
#FASTFV_FLANN_NCOMPARISONS = 32
8+
#FASTFV_QUANTIZER = --enableflann $(FASTFV_FLANN_NTREES) $(FASTFV_FLANN_NCOMPARISONS)
9+
10+
# comment next line to disable s-t grids
11+
FV_SPATIO_TEMPORAL_GRIDS = --enablespatiotemporalgrids
12+
13+
# comment next line and uncomment the one after to use yael
14+
FV = $(FASTFV)
15+
#FV = ../yaelfv.py
16+
17+
# Tools paths
18+
FASTVIDEOFEAT = ../../bin/fastvideofeat
19+
FASTFV = ../../bin/fastfv
20+
YAELDIR = ../../bin/dependencies/yael/yael
21+
export PYTHONPATH := $(shell pwd)/$(YAELDIR):$(PYTHONPATH)
22+
23+
# repro below
24+
clipFile = allClips.txt
25+
allClips = $(shell cat $(clipFile))
26+
27+
videoDir = data/dataset/avi
28+
evalDir = data/dataset/testTrainMulti_7030_splits
29+
recodedDir = data/dataset/avi_recoded
30+
31+
dataset = $(addprefix $(videoDir)/, $(allClips))
32+
features = $(addprefix data/features/, $(addsuffix .txt, $(allClips)))
33+
features_sampled = data/features_sampled.txt
34+
vocabs = $(addprefix data/vocabs/, 10-105.hog.gmm 106-213.hog.gmm 214-309.mbhx.gmm 310-405.mbhy.gmm)
35+
fisher_vectors = $(addprefix data/fisher_vectors/, $(addsuffix .txt, $(allClips)))
36+
kernel = data/kernel.txt
37+
classification = data/classification.txt
38+
report = data/report.txt
39+
artefactDirs = data/features data/vocabs data/fisher_vectors data/dataset/avi_recoded logs/features logs/fisher_vectors logs/vocabs logs/recoding
40+
41+
log = $(subst data, logs, $@).log
42+
vocab = $(basename $(basename $(notdir $(1)))) $(1)
43+
44+
all: $(report)
45+
echo "Report on HMDB-51 classification task."
46+
echo "Reported accuracies are accuracies on dataset splits."
47+
echo ""
48+
cat $(report)
49+
50+
$(artefactDirs) data/dataset:
51+
mkdir -p $@
52+
53+
$(dataset): $(videoDir)
54+
55+
$(features): $(dataset) | $(artefactDirs)
56+
ffmpeg -y -an -i $(videoDir)/$(basename $(notdir $@)) -vcodec libxvid -q:v 1 $(recodedDir)/$(basename $(notdir $@)) > $(subst features,recoding, $(log)) 2>&1
57+
$(FASTVIDEOFEAT) $(recodedDir)/$(basename $(notdir $@)) > $@ 2> $(log)
58+
59+
$(features_sampled): $(features)
60+
awk '{ if (rand() <= .01) print }' data/features/* > $@
61+
62+
$(vocabs): $(features_sampled)
63+
cat $(features_sampled) | ../../src/gmm_train.py --gmm_ncomponents $(FV_GMM_NCOMPONENTS) --vocab $(call vocab, $@) > $(log) 2>&1
64+
65+
$(fisher_vectors): $(features) $(vocabs)
66+
cat $(subst fisher_vectors,features, $@) | $(FV) --xpos 0 --ypos 1 --tpos 2 --knn $(FASTFV_KNN) $(FASTFV_QUANTIZER) $(FV_SPATIO_TEMPORAL_GRIDS) $(foreach g, $(vocabs), --vocab $(call vocab, $(g))) > $@ 2> $(log)
67+
68+
$(kernel) : $(fisher_vectors)
69+
../dot_kernel.py data/fisher_vectors $(clipFile) > $@
70+
71+
$(classification) : $(kernel)
72+
cat $(kernel) | ./classify.py $(evalDir) $(clipFile) > $@
73+
74+
$(report): $(classification)
75+
../report.py > $@
76+
77+
$(videoDir): | data/dataset
78+
wget http://www.rarlab.com/rar/rarlinux-3.9.1.tar.gz
79+
wget http://serre-lab.clps.brown.edu/wp-content/uploads/2013/10/hmdb51_org.rar
80+
wget http://serre-lab.clps.brown.edu/wp-content/uploads/2013/10/test_train_splits.rar
81+
mkdir -p $(videoDir)
82+
tar -C data/dataset -xf rarlinux-3.9.1.tar.gz
83+
data/dataset/rar/unrar x test_train_splits.rar data/dataset
84+
data/dataset/rar/unrar x hmdb51_org.rar $(videoDir)
85+
data/dataset/rar/unrar x '$(videoDir)/*.rar' $(videoDir)
86+
find $(videoDir) -name '*.avi' -exec bash -c 'mv "{}" $(videoDir)/$$(echo $$(basename "{}") | sed "s/[][;()&?!]/_/g")' \; 2> /dev/null
87+
rm rarlinux-3.9.1.tar.gz hmdb51_org.rar test_train_splits.rar $(videoDir)/*.rar
88+
89+
clean:
90+
rm -rf $(artefactDirs) $(features_sampled) $(kernel) $(classification) $(report)

repro/hmdb-51/README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Reproducing HMDB-51 results
2+
3+
## Prerequisites
4+
- 64-bit *nix, 800 Gb of free disk space, several gigs of RAM
5+
- Python, NumPy, scikits-learn, PyYAML, ffmpeg with libxvid
6+
7+
## Instructions
8+
9+
Make sure all prerequisites are in place. Put the tools binaries in *bin* (you can get them from the [releases page](http://github.com/vadimkantorov/cvpr2014/releases)), and then run the repro with:
10+
> $ make --jobs 8
11+
12+
The script will automatically download the HMDB-51 dataset and rar decompressor that are required for evaluation.
13+
You can adjust the number of cores used for parallel execution. In about an hour the scripts will fill the data and logs directories. After execution you will see a report like:
14+
```
15+
Report on HMDB-51 classification task.
16+
Reported accuracies are accuracies on dataset splits.
17+
18+
Average frame count: 95
19+
Average frame size: 366x240
20+
Average descriptor count: 62462
21+
22+
All fps are reported without taking file reading and writing into account, howevere, video decoding is included.
23+
24+
Features (HOF, HOG, MBH enabled):
25+
Average total fps: 775.76
26+
Average HOG fps: 3807.06
27+
Average HOF fps: 4364.18
28+
Average MBH fps: 2840.89
29+
30+
Fisher vectors (components: 256, s-t grids enabled: True, knn: 5, second order enabled: False, FLANN trees: -1, FLANN comparisons: -1):
31+
Average total fps: 632.27
32+
33+
Classification:
34+
split_0 0.4588
35+
split_1 0.4359
36+
split_2 0.4595
37+
38+
mean: 0.4514
39+
```
40+
41+
To remove all produced items (no worry, it will not remove the downloaded Hollywood-2 dataset), run:
42+
> $ make clean
43+
44+
# Notes
45+
The code recodes HMDB-51 videos with libxvid to produce reasonable motion vectors, as original videos in HMDB-51 are quite messy.
46+
Key parameters are specified on top of the Makefile and explained in the [Performance section](https://github.com/vadimkantorov/cvpr2014/#performance). You could play with them, hopefully everything will still work.
47+
Features and Fisher vectors are not compressed for the sake of script clarity. For practical usage, feel free to modify the script to use gzip compression or modify the tools to output floats in binary format.

0 commit comments

Comments
 (0)