Skip to content
Snippets Groups Projects
Select Git revision
  • e2f6395be10ef484ef4ac04ff48ebe79170689a6
  • master default protected
  • enxhi_issue460_remove_TOAR-I_access
  • michael_issue459_preprocess_german_stations
  • sh_pollutants
  • develop protected
  • release_v2.4.0
  • michael_issue450_feat_load-ifs-data
  • lukas_issue457_feat_set-config-paths-as-parameter
  • lukas_issue454_feat_use-toar-statistics-api-v2
  • lukas_issue453_refac_advanced-retry-strategy
  • lukas_issue452_bug_update-proj-version
  • lukas_issue449_refac_load-era5-data-from-toar-db
  • lukas_issue451_feat_robust-apriori-estimate-for-short-timeseries
  • lukas_issue448_feat_load-model-from-path
  • lukas_issue447_feat_store-and-load-local-clim-apriori-data
  • lukas_issue445_feat_data-insight-plot-monthly-distribution
  • lukas_issue442_feat_bias-free-evaluation
  • lukas_issue444_feat_choose-interp-method-cams
  • 414-include-crps-analysis-and-other-ens-verif-methods-or-plots
  • lukas_issue384_feat_aqw-data-handler
  • v2.4.0 protected
  • v2.3.0 protected
  • v2.2.0 protected
  • v2.1.0 protected
  • Kleinert_etal_2022_initial_submission
  • v2.0.0 protected
  • v1.5.0 protected
  • v1.4.0 protected
  • v1.3.0 protected
  • v1.2.1 protected
  • v1.2.0 protected
  • v1.1.0 protected
  • IntelliO3-ts-v1.0_R1-submit
  • v1.0.0 protected
  • v0.12.2 protected
  • v0.12.1 protected
  • v0.12.0 protected
  • v0.11.0 protected
  • v0.10.0 protected
  • IntelliO3-ts-v1.0_initial-submit
41 results

create_runscripts_HPC.sh

Blame
  • download_and_preprocess_dataset_v1.sh 3.39 KiB
    #!/usr/bin/env bash
    
    # exit if any command fails
    set -e
    
    if [ "$#" -eq 2 ]; then
      if [ $1 = "bair" ]; then
        echo "IMAGE_SIZE argument is only applicable to kth dataset" >&2
        exit 1
      fi
    elif [ "$#" -ne 1 ]; then
      echo "Usage: $0 DATASET_NAME [IMAGE_SIZE]" >&2
      exit 1
    fi
    if [ $1 = "bair" ]; then
      TARGET_DIR=./data/bair
      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} Bing: on MacOS system , use curl instead of wget
      curl ${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.tfrecords ${TARGET_DIR}/val/
    elif [ $1 = "kth" ]; then
      if [ "$#" -eq 2 ]; then
        IMAGE_SIZE=$2
        TARGET_DIR=./data/kth_${IMAGE_SIZE}
      else
        IMAGE_SIZE=64
        TARGET_DIR=./data/kth
      fi
      echo ${TARGET_DIR} ${IMAGE_SIZE}
      mkdir -p ${TARGET_DIR}
      mkdir -p ${TARGET_DIR}/raw
      echo "Downloading '$1' dataset (this takes a while)"
      # TODO Bing: for save time just use walking, need to change back if all the data are needed
      #for ACTION in walking jogging running boxing handwaving handclapping; do
    #  for ACTION in walking; do
    #    echo "Action: '$ACTION' "
    #    ZIP_FNAME=${ACTION}.zip
    #    URL=http://www.nada.kth.se/cvap/actions/${ZIP_FNAME}
    #   # wget ${URL} -O ${TARGET_DIR}/raw/${ZIP_FNAME}
    #    echo "Start downloading action '$ACTION' ULR '$URL' "
    #    curl ${URL} -O ${TARGET_DIR}/raw/${ZIP_FNAME}
    #    unzip ${TARGET_DIR}/raw/${ZIP_FNAME} -d ${TARGET_DIR}/raw/${ACTION}
    #    echo "Action '$ACTION' data download and unzip "
    #  done
      FRAME_RATE=25
    #  mkdir -p ${TARGET_DIR}/processed
    #  # download files with metadata specifying the subsequences
    #  TAR_FNAME=kth_meta.tar.gz
    #  URL=http://rail.eecs.berkeley.edu/models/savp/data/${TAR_FNAME}
    #  echo "Downloading '${TAR_FNAME}' ULR '$URL' "
    #  #wget ${URL} -O ${TARGET_DIR}/processed/${TAR_FNAME}
    #  curl ${URL} -O ${TARGET_DIR}/processed/${TAR_FNAME}
    #  tar -xzvf ${TARGET_DIR}/processed/${TAR_FNAME} --strip 1 -C ${TARGET_DIR}/processed
      # convert the videos into sequence of downscaled images
      echo "Processing '$1' dataset"
      #TODO Bing, just use walking for test
      #for ACTION in walking jogging running boxing handwaving handclapping; do
      #Todo Bing: remove the comments below after testing
      for ACTION in walking; do
        for VIDEO_FNAME in ${TARGET_DIR}/raw/${ACTION}/*.avi; do
          FNAME=$(basename ${VIDEO_FNAME})
          FNAME=${FNAME%_uncomp.avi}
          echo "FNAME '$FNAME' "
          # sometimes the directory is not created, so try until it is
          while [ ! -d "${TARGET_DIR}/processed/${ACTION}/${FNAME}" ]; do
            mkdir -p ${TARGET_DIR}/processed/${ACTION}/${FNAME}
          done
          ffmpeg -i ${VIDEO_FNAME} -r ${FRAME_RATE} -f image2 -s ${IMAGE_SIZE}x${IMAGE_SIZE} \
          ${TARGET_DIR}/processed/${ACTION}/${FNAME}/image-%03d_${IMAGE_SIZE}x${IMAGE_SIZE}.png
        done
      done
      python video_prediction/datasets/kth_dataset.py ${TARGET_DIR}/processed ${TARGET_DIR} ${IMAGE_SIZE}
      rm -rf ${TARGET_DIR}/raw
      rm -rf ${TARGET_DIR}/processed
    else
      echo "Invalid dataset name: '$1' (choose from 'bair', 'kth')" >&2
      exit 1
    fi
    echo "Succesfully finished downloading and preprocessing dataset '$1'"