SINGA-278 Convert trained caffe parameters to singa Update the running instructions in the readme file
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/eca642bc Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/eca642bc Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/eca642bc Branch: refs/heads/master Commit: eca642bc6f542dcdd3220f148b50521b5619c2ae Parents: bd41fd1 Author: wangwei <[email protected]> Authored: Tue Dec 20 22:12:19 2016 +0800 Committer: wangwei <[email protected]> Committed: Tue Dec 20 22:12:19 2016 +0800 ---------------------------------------------------------------------- examples/caffe/README.md | 9 +-------- examples/caffe/predict.py | 6 +++--- examples/caffe/run.sh | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/eca642bc/examples/caffe/README.md ---------------------------------------------------------------------- diff --git a/examples/caffe/README.md b/examples/caffe/README.md index af14d27..92c9325 100644 --- a/examples/caffe/README.md +++ b/examples/caffe/README.md @@ -25,15 +25,8 @@ The `predict.py` script creates the VGG model and read the parameters, where `imgclass` refers to the synsets of imagenet dataset for vgg models. You can start the prediction program by executing the following command: - python predict.py ./vgg16.prototxt ./vgg16.caffemodel ./synset_words.txt + python predict.py vgg16.prototxt vgg16.caffemodel synset_words.txt Then you type in the image path, and the program would output the top-5 labels. -**NOTE** Caffe uses OpenCV to load images, whose channels are in BGR order. To -do prediction using Caffe's pre-trained parameters, please make sure the input -tensor of SINGA net is in BGR order. cv2 loads images as BGR, hence you don't need -to do any additional processing. If you use pillow to read images, you need to -swap the channel as shown in predict.py. - - More Caffe models would be tested soon. http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/eca642bc/examples/caffe/predict.py ---------------------------------------------------------------------- diff --git a/examples/caffe/predict.py b/examples/caffe/predict.py index 9ef34ed..663cd87 100644 --- a/examples/caffe/predict.py +++ b/examples/caffe/predict.py @@ -90,9 +90,9 @@ if __name__ == '__main__': description='Convert caffe vgg into singa. \ This tool only supports caffe model in current version(29-Nov-2016). \ You can use caffe tool to update previous model') - parser.add_argument('--model_txt', default='./vgg16.prototxt') - parser.add_argument('--model_bin', default='./vgg16.caffemodel') - parser.add_argument('--imgclass', default='./synset_words.txt') + parser.add_argument('model_txt', default='./vgg16.prototxt') + parser.add_argument('model_bin', default='./vgg16.caffemodel') + parser.add_argument('imgclass', default='./synset_words.txt') args = parser.parse_args() check_path(args.model_txt) http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/eca642bc/examples/caffe/run.sh ---------------------------------------------------------------------- diff --git a/examples/caffe/run.sh b/examples/caffe/run.sh index 4845f7b..d33d1f7 100755 --- a/examples/caffe/run.sh +++ b/examples/caffe/run.sh @@ -24,7 +24,7 @@ if [[ $1 == "vgg19" ]]; then tar -zxvf test.tar.gz fi echo "Converting..." - python predict.py ./vgg19.prototxt ./vgg19.caffemodel ./synset_words.txt ./test + python predict.py ./vgg19.prototxt ./vgg19.caffemodel ./synset_words.txt elif [[ $1 == "vgg16" ]]; then echo "Downloading label list..." @@ -45,7 +45,7 @@ elif [[ $1 == "vgg16" ]]; then tar -zxvf test.tar.gz fi echo "Converting..." - python predict.py ./vgg16.prototxt ./vgg16.caffemodel ./synset_words.txt ./test + python predict.py ./vgg16.prototxt ./vgg16.caffemodel ./synset_words.txt else echo "unsupported model: $1" fi
