Created
February 13, 2017 22:18
-
-
Save jeffdonahue/9925beb2d1760d880862443f19aed8e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -x | |
GPU=0 | |
CWD=$(pwd) | |
CAFFE_DIR=/raid/jdonahue/philkr-caffe | |
MAGIC_DIR=~/magic_init | |
CLASS_DIR=/raid/jdonahue/voc-classification | |
H5DATA_DIR=${CLASS_DIR}/output | |
REINIT_LAYER=fc6 | |
TRAIN_FROM=fc6 | |
# TRAIN_FROM=conv1 | |
MODEL=400_encode_params | |
MODEL_DIR=./exp/imagenet_100_gs-1000_allcond_alexnetgroupencode_jointdiscrim_steps1_quadtrain_96encinputelse64_mblayer300-50-16_encoutbias/models | |
MODEL_DEF=${CAFFE_DIR}/models/bvlc_reference_caffenet/train_val_zero.nolrn.lrelu.prototxt | |
REINIT_CAFFEMODEL_PATH=${MODEL_DIR}/${MODEL}.kmeans_reinit_from_${REINIT_LAYER}.zero_fc8.cs.caffemodel | |
RESIZE= | |
# RESIZE=256 | |
MODEL_PATH=${MODEL_DIR}/${MODEL}.jl | |
CAFFEMODEL_PATH=${MODEL_DIR}/${MODEL}.caffemodel | |
MODEL_PATH=$(realpath ${MODEL_PATH}) | |
CAFFEMODEL_PATH=$(realpath ${CAFFEMODEL_PATH}) | |
REINIT_CAFFEMODEL_PATH=$(realpath ${REINIT_CAFFEMODEL_PATH}) | |
export GLOG_minloglevel=3 | |
export PYTHONPATH=$CAFFE_DIR/python | |
export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:/home/jdonahue/cudnn3/cuda/lib64:/opt/intel/lib/intel64:/opt/intel/mkl/lib:/opt/intel/mkl/lib/intel64:/usr/local/cuda/lib64:/usr/local/lib:/usr/lib:/lib:/home/jdonahue/anaconda/lib:/home/jdonahue/cudnn4/cuda/lib64 | |
if [ ! -e "${CAFFEMODEL_PATH}" ]; then | |
cd ${CAFFE_DIR} | |
python ${CWD}/export_params.py ${MODEL_DEF} ${MODEL_PATH} ${CAFFEMODEL_PATH} | |
fi | |
if [ ! -e "${REINIT_CAFFEMODEL_PATH}" ]; then | |
cd ${CAFFE_DIR} | |
python ${MAGIC_DIR}/magic_init.py -l ${CAFFEMODEL_PATH} --zero_from ${REINIT_LAYER} --post_zero_from fc8 -cs --gpu ${GPU} -t kmeans ${MODEL_DEF} ${REINIT_CAFFEMODEL_PATH} | |
fi | |
OUTPUT_DIR=$(mktemp -d) | |
cd ${OUTPUT_DIR} | |
ln -s ${H5DATA_DIR}/*.hf5 . | |
cd ${CLASS_DIR} | |
MEAN=127.5,127.5,127.5 | |
SCALE=0.0078431368 | |
if [ -z "$RESIZE" ]; then | |
RESIZE_ARG="" | |
else | |
RESIZE_ARG="--resize ${RESIZE}" | |
fi | |
MEAN_ARG="--mean_value ${MEAN}" | |
SCALE_ARG="--scale ${SCALE}" | |
python src/train_cls.py ${MODEL_DEF} ${REINIT_CAFFEMODEL_PATH} ${MEAN_ARG} ${SCALE_ARG} --output-dir ${OUTPUT_DIR} --train-from ${TRAIN_FROM} --gpu ${GPU} ${RESIZE_ARG} | |
cd ${CWD} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment