From 1446bfc2fbd6516cb9b079d41fc86e4ad6086ace Mon Sep 17 00:00:00 2001 From: Mu Li Date: Mon, 19 Dec 2016 17:17:18 -0800 Subject: [PATCH] [image-classification] default use min_random_scale=1, add data/imagenet1k-val.sh (#4295) --- .../data/imagenet1k-val.sh | 22 +++++++++++++++++++ .../image-classification/train_imagenet.py | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 example/image-classification/data/imagenet1k-val.sh diff --git a/example/image-classification/data/imagenet1k-val.sh b/example/image-classification/data/imagenet1k-val.sh new file mode 100755 index 000000000000..51f8130103fd --- /dev/null +++ b/example/image-classification/data/imagenet1k-val.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# This file download the imagnet-1k validation dataset and convert it into a rec +# file. One need to provide the URL for the ILSVRC2012_img_val.tar, which can be +# find at http://www.image-net.org/download-images +# +# Example usage (replace the URL with the correct one): +# ./imagenet1k-val.sh http://xxxxxx/challenges/LSVRC/2012/nnoupb/ILSVRC2012_img_val.tar + +if [ ! -e ILSVRC2012_img_val.tar ]; then + wget $1 +fi +mkdir -p val +tar -xf ILSVRC2012_img_val.tar -C val +wget http://data.mxnet.io/models/imagenet/resnet/val.lst -O imagenet1k-val.lst + +CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +MX_DIR=${CUR_DIR}/../../../ + +python ${CUR_DIR}/../../../tools/im2rec.py --resize 256 --quality 90 --num-thread 16 imagenet1k-val val/ + +rm -rf val diff --git a/example/image-classification/train_imagenet.py b/example/image-classification/train_imagenet.py index 432393e57044..db190275a18b 100644 --- a/example/image-classification/train_imagenet.py +++ b/example/image-classification/train_imagenet.py @@ -23,7 +23,8 @@ num_classes = 1000, num_examples = 1281167, image_shape = '3,224,224', - min_random_scale = 0.533, # assume input image has min size 480, 0.533 = 256/480 + min_random_scale = 1, # if input image has min size k, suggest to use + # 256.0/x, e.g. 0.533 for 480 # train num_epochs = 80, lr_step_epochs = '30,60',