Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 58A98200C2C for ; Fri, 17 Feb 2017 07:24:58 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 571B5160B6F; Fri, 17 Feb 2017 06:24:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 77CA9160B61 for ; Fri, 17 Feb 2017 07:24:57 +0100 (CET) Received: (qmail 13784 invoked by uid 500); 17 Feb 2017 06:24:56 -0000 Mailing-List: contact commits-help@singa.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.incubator.apache.org Delivered-To: mailing list commits@singa.incubator.apache.org Received: (qmail 13775 invoked by uid 99); 17 Feb 2017 06:24:56 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2017 06:24:56 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 48067C0EF4 for ; Fri, 17 Feb 2017 06:24:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id iesGXvApyohb for ; Fri, 17 Feb 2017 06:24:55 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 0C6195F370 for ; Fri, 17 Feb 2017 06:24:53 +0000 (UTC) Received: (qmail 12640 invoked by uid 99); 17 Feb 2017 06:24:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2017 06:24:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4ACB9DFC63; Fri, 17 Feb 2017 06:24:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wangsh@apache.org To: commits@singa.incubator.apache.org Date: Fri, 17 Feb 2017 06:24:07 -0000 Message-Id: <5dae978fc33a4c49802f748ed49bad78@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/5] incubator-singa git commit: SINGA-300 - Add residual networks for imagenet classification archived-at: Fri, 17 Feb 2017 06:24:58 -0000 SINGA-300 - Add residual networks for imagenet classification Add license header and 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/026db89d Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/026db89d Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/026db89d Branch: refs/heads/master Commit: 026db89d4899b51c8bf216f08edec580305c5e15 Parents: 45ec92d Author: Wei Wang Authored: Sun Feb 12 22:07:01 2017 +0800 Committer: Wei Wang Committed: Fri Feb 17 12:59:19 2017 +0800 ---------------------------------------------------------------------- examples/imagenet/resnet/README.md | 54 ++++++++++++++++++++++++++++++++ examples/imagenet/resnet/convert.py | 22 +++++++++++-- examples/imagenet/resnet/serve.py | 16 ++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/026db89d/examples/imagenet/resnet/README.md ---------------------------------------------------------------------- diff --git a/examples/imagenet/resnet/README.md b/examples/imagenet/resnet/README.md new file mode 100644 index 0000000..4d5f231 --- /dev/null +++ b/examples/imagenet/resnet/README.md @@ -0,0 +1,54 @@ +--- +name: Resnets on ImageNet +SINGA version: 1.1 +SINGA commit: 45ec92d8ffc1fa1385a9307fdf07e21da939ee2f +parameter_url: https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-18.tar.gz +license: Apache V2, https://github.com/facebook/fb.resnet.torch/blob/master/LICENSE +--- + +# Image Classification using Residual Networks + + +In this example, we convert Residual Networks trained on [Torch](https://github.com/facebook/fb.resnet.torch) to SINGA for image classification. + +## Instructions + +* Download one parameter checkpoint file (see below) and the synset word file of ImageNet into this folder, e.g., + + $ wget https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-18.tar.gz + $ wget https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/synset_words.txt + $ tar xvf resnet-18.tar.gz + +* Usage + + $ python serve.py -h + +* Example + + # use cpu + $ python serve.py -C --parameter_file resnet-18.pickle --model resnet --depth 18 & + # use gpu + $ python serve.py --parameter_file resnet-18.pickle --model resnet --depth 18 & + + The parameter files for the following model and depth configuration pairs are provided: + * resnet (original resnet), [18](https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-101.tar.gz)|[34](https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-34.tar.gz)|[101](https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-101.tar.gz)|[152](https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-152.tar.gz) + * addbn (resnet with a batch normalization layer after the addition), [50](https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-50.tar.gz) + * wrn (wide resnet), [50](https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/wrn-50-2.tar.gz) + * preact (resnet with pre-activation) [200](https://s3-ap-southeast-1.amazonaws.com/dlfile/resnet/resnet-200.tar.gz) + +* Submit images for classification + + $ curl -i -F image=@image1.jpg http://localhost:9999/api + $ curl -i -F image=@image2.jpg http://localhost:9999/api + $ curl -i -F image=@image3.jpg http://localhost:9999/api + +image1.jpg, image2.jpg and image3.jpg should be downloaded before executing the above commands. + +## Details + +The parameter files were extracted from the original [torch files](https://github.com/facebook/fb.resnet.torch/tree/master/pretrained) via +the convert.py program. + +Usage: + + $ python convert.py -h http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/026db89d/examples/imagenet/resnet/convert.py ---------------------------------------------------------------------- diff --git a/examples/imagenet/resnet/convert.py b/examples/imagenet/resnet/convert.py index e630281..6bf4101 100644 --- a/examples/imagenet/resnet/convert.py +++ b/examples/imagenet/resnet/convert.py @@ -1,12 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +'''Extract the net parameters from the torch file and store them as python dict +using cPickle''' + import os import torchfile import numpy as np import cPickle as pickle from argparse import ArgumentParser -'''Extract the net parameters from the torch file and store them as python dict -using cPickle''' - import model verbose=False http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/026db89d/examples/imagenet/resnet/serve.py ---------------------------------------------------------------------- diff --git a/examples/imagenet/resnet/serve.py b/examples/imagenet/resnet/serve.py index a6163f7..aea7b18 100644 --- a/examples/imagenet/resnet/serve.py +++ b/examples/imagenet/resnet/serve.py @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import sys import time