Skip to content

Commit

Permalink
kth data download and process scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
edenton committed Mar 26, 2018
1 parent 65c09e5 commit 6984074
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -27,3 +27,19 @@ To generate images with a pretrained SVG-LP model run:
```
python generate_svg_lp.py --model_path pretrained_models/svglp_bair.pth --log_dir /generated/images/will/save/here/
```


## KTH action dataset
First download the KTH action recognition dataset by running:
```
sh data/download_kth.sh /my/kth/data/path/
```
where /my/kth/data/path/ is the directory the data will be downloaded into. Next, convert the downloaded .avi files into .png's for the data loader. To do this you'll want [ffmpeg](https://ffmpeg.org/) installed. The following script will do the conversion, but beware, it's written in lua (sorry!):
```
th data/convert_kth.lua --dataRoot /my/kth/data/path/ --imageSize 128
```
The ```--imageSize``` flag specifiec the image resolution. Experimental results in the paper used 128x128, but you can also train a model on 64x64 and it will train much faster.
To train the SVG-FP model on 64x64 KTH videos run:
```
python train_svg_fp.py --dataset kth --image_width 64 --model vgg --g_dim 128 --z_dim 24 --beta 0.000001 --n_past 10 --n_future 10 --channels 1 --lr 0.0008 --data_root /path/to/data/ --log_dir /logs/will/be/saved/here/
```
28 changes: 28 additions & 0 deletions data/convert_kth.lua
@@ -0,0 +1,28 @@
require 'paths'

opt = lapp[[
--imageSize (default 128) size of image
--dataRoot (default '/path/to/data/') data root directory
]]
image_size = opt.imageSize
data_root = opt.dataRoot
if not paths.dir(data_root) then
error(('Error with data directory: %s'):format(data_root))
end

classes = {'boxing', 'handclapping', 'handwaving', 'jogging', 'running', 'walking'}

frame_rate = 25

for _, class in pairs(classes) do
print(' ---- ')
print(class)

for vid in paths.iterfiles(data_root .. '/raw/' .. class) do
print(vid)
local fname = vid:sub(1,-12)
os.execute(('mkdir -p %s/processed/%s/%s'):format(data_root, class, fname))
os.execute( ('~/tools/ffmpeg-git-20170417-32bit-static/ffmpeg -i %s/raw/%s/%s -r %d -f image2 -s %dx%d %s/processed/%s/%s/image-%%03d_%dx%d.png'):format(data_root, class, vid, frame_rate, image_size, image_size, data_root, class, fname, image_size, image_size))
end
end

22 changes: 22 additions & 0 deletions data/download_kth.sh
@@ -0,0 +1,22 @@
TARGET_DIR=$1
if [ -z $TARGET_DIR ]
then
echo "Must specify target directory"
else
mkdir $TARGET_DIR/processed
mkdir $TARGET_DIR/raw
URL=http://www.cs.nyu.edu/~denton/datasets/kth.tar.gz
wget $URL -P $TARGET_DIR/processed
tar -zxvf $TARGET_DIR/processed/kth.tar.gz -C $TARGET_DIR/processed/
rm $TARGET_DIR/processed/kth.tar.gz

for c in walking jogging running handwaving handclapping boxing
do
URL=http://www.nada.kth.se/cvap/actions/"$c".zip
wget $URL -P $TARGET_DIR/raw
mkdir $TARGET_DIR/raw/$c
unzip $TARGET_DIR/raw/"$c".zip -d $TARGET_DIR/raw/$c
rm $TARGET_DIR/raw/"$c".zip
done

fi

0 comments on commit 6984074

Please sign in to comment.