From 17f170067a13dc1bf1fcb7cad95b70fb5f93b8e7 Mon Sep 17 00:00:00 2001
From: Alex Lee <alexleegk@gmail.com>
Date: Sat, 7 Apr 2018 18:35:39 -0700
Subject: [PATCH] Add script to download and preprocess datasets.

---
 data/bibtex/kth.txt                     |  6 +++++
 data/bibtex/sna.txt                     |  6 +++++
 data/download_and_preprocess_dataset.sh | 36 +++++++++++++++++++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 data/bibtex/kth.txt
 create mode 100644 data/bibtex/sna.txt
 create mode 100644 data/download_and_preprocess_dataset.sh

diff --git a/data/bibtex/kth.txt b/data/bibtex/kth.txt
new file mode 100644
index 00000000..ef223ac6
--- /dev/null
+++ b/data/bibtex/kth.txt
@@ -0,0 +1,6 @@
+@inproceedings{schuldt2004kth,
+  title={Recognizing human actions: a local {SVM} approach},
+  author={Schuldt, Christian and Laptev, Ivan and Caputo, Barbara},
+  booktitle={International Conference on Pattern Recognition (ICPR)},
+  year={2004},
+}
diff --git a/data/bibtex/sna.txt b/data/bibtex/sna.txt
new file mode 100644
index 00000000..f458d1fc
--- /dev/null
+++ b/data/bibtex/sna.txt
@@ -0,0 +1,6 @@
+@inproceedings{ebert17sna,
+  title={Self-Supervised Visual Planning with Temporal Skip Connections},
+  author={Ebert, Frederik, and Finn, Chelsea and Lee, Alex and Levine, Sergey},
+  booktitle={Conference on Robot Learning (CoRL)},
+  year={2017}
+}
diff --git a/data/download_and_preprocess_dataset.sh b/data/download_and_preprocess_dataset.sh
new file mode 100644
index 00000000..a0fe6b9b
--- /dev/null
+++ b/data/download_and_preprocess_dataset.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+if [ "$#" -ne 1 ]; then
+  echo "Usage: $0 DATASET_NAME" >&2
+  exit 1
+fi
+if [ $1 = "bair" ]; then
+  TARGET_DIR=./data/softmotion30_44k
+  mkdir -p ${TARGET_DIR}
+  TAR_FNAME=bair_robot_pushing_dataset_v0.tar
+  URL=http://rail.eecs.berkeley.edu/datasets/${TAR_FNAME}
+  echo "Downloading $1 dataset (this takes a while)"
+  wget ${URL} -O ${TARGET_DIR}/${TAR_FNAME}
+  tar -xvf ${TARGET_DIR}/${TAR_FNAME} --strip-components=1 -C ${TARGET_DIR}
+  rm ${TARGET_DIR}/${TAR_FNAME}
+  mkdir -p ${TARGET_DIR}/val
+  # reserve a fraction of the training set for validation
+  mv ${TARGET_DIR}/train/traj_{256_to_511,512_to_767,768_to_1023,1024_to_1279,1280_to_1535,1536_to_1791,1792_to_2047,2048_to_2303,2304_to_2559}.tfrecords ${TARGET_DIR}/val/
+elif [ $1 = "kth" ]; then
+  TARGET_DIR=./data/kth
+  mkdir -p ${TARGET_DIR}
+  mkdir -p ${TARGET_DIR}/raw
+  echo "Downloading $1 dataset (this takes a while)"
+  for ACTION in walking jogging running boxing handwaving handclapping; do
+    ZIP_FNAME=${ACTION}.zip
+    URL=http://www.nada.kth.se/cvap/actions/${ZIP_FNAME}
+    wget ${URL} -O ${TARGET_DIR}/raw/${ZIP_FNAME}
+    unzip ${TARGET_DIR}/raw/${ZIP_FNAME} -d ${TARGET_DIR}/raw/${ACTION}
+  done
+  python video_prediction/datasets/kth_dataset.py ${TARGET_DIR}/raw ${TARGET_DIR}
+  rm -rf ${TARGET_DIR}/raw
+else
+  echo "Invalid dataset name: '$1' (choose from 'bair', 'kth')" >&2
+  exit 1
+fi
+echo "Succesfully finished downloading and preprocessing dataset $1"
-- 
GitLab