1#!/bin/bash
2
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements.  See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership.  The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance
9# with the License.  You may obtain a copy of the License at
10#
11#   http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing,
14# software distributed under the License is distributed on an
15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16# KIND, either express or implied.  See the License for the
17# specific language governing permissions and limitations
18# under the License.
19
20if [[ $# -ne 1 ]]; then
21    echo "usage: $0 model_name"
22    echo "   model_name: [vgg16|vgg19], ..."
23    exit -1
24fi
25
26if [[ $1 == "vgg19" ]]; then
27    if [[ ! -f VGG_ILSVRC_19_layers_deploy.prototxt ]]; then
28        wget -c https://gist.githubusercontent.com/ksimonyan/3785162f95cd2d5fee77/raw/bb2b4fe0a9bb0669211cf3d0bc949dfdda173e9e/VGG_ILSVRC_19_layers_deploy.prototxt
29    fi
30
31    if [[ ! -f VGG_ILSVRC_19_layers.caffemodel ]]; then
32        wget -c http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_19_layers.caffemodel
33    fi
34
35    echo "converting"
36    python `dirname $0`/convert_model.py VGG_ILSVRC_19_layers_deploy.prototxt VGG_ILSVRC_19_layers.caffemodel vgg19
37elif [[ $1 == "vgg16" ]]; then
38    if [[ ! -f VGG_ILSVRC_16_layers_deploy.prototxt ]]; then
39        wget -c https://gist.githubusercontent.com/ksimonyan/211839e770f7b538e2d8/raw/c3ba00e272d9f48594acef1f67e5fd12aff7a806/VGG_ILSVRC_16_layers_deploy.prototxt
40    fi
41
42    if [[ ! -f VGG_ILSVRC_16_layers.caffemodel ]]; then
43        wget -c http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel
44    fi
45
46    echo "converting"
47    python `dirname $0`/convert_model.py VGG_ILSVRC_16_layers_deploy.prototxt VGG_ILSVRC_16_layers.caffemodel vgg16
48else
49    echo "unsupported model: $1"
50fi
51