model_download.sh 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#! /usr/bin/env bash

function download() {
    URL=$1
    MD5=$2
    TARGET=$3

    if [ -e $TARGET ]; then
        md5_result=`md5sum $TARGET | awk -F[' '] '{print $1}'`
        if [ $MD5 == $md5_result ]; then
            echo "$TARGET already exists, download skipped."
            return 0
        fi
    fi

    wget -c $URL -O "$TARGET"
    if [ $? -ne 0 ]; then
        return 1
    fi

    md5_result=`md5sum $TARGET | awk -F[' '] '{print $1}'`
    if [ ! $MD5 == $md5_result ]; then
        return 1
    fi
}

case "$1" in
    "ResNet50")
		URL="http://cloud.dlnel.org/filepub/?uuid=f63f237a-698e-4a22-9782-baf5bb183019"
		MD5="eb4d7b5962c9954340207788af0d6967"	 
        ;;
    "ResNet101")
		URL="http://cloud.dlnel.org/filepub/?uuid=3d5fb996-83d0-4745-8adc-13ee960fc55c"
		MD5="7e71f24998aa8e434fa164a7c4fc9c02"
        ;;
    "Vgg16")
		URL="http://cloud.dlnel.org/filepub/?uuid=aa0e397e-474a-4cc1-bd8f-65a214039c2e"
		MD5="e73dc42507e6acd3a8b8087f66a9f395"
        ;;
    *)
        echo "The "$1" model is not provided currently."
		exit 1
        ;;
esac
TARGET="Paddle_"$1".tar.gz"

echo "Download "$1" model ..."
download $URL $MD5 $TARGET
if [ $? -ne 0 ]; then
    echo "Fail to download the model!"
    exit 1
fi


exit 0