tree: 26af06a857ecd1b83c2d105d68ae13c1dbd12d1a [path history] [tgz]
  1. README.md
doc/zh/docs/model_zoo/imagenet/resnet/README.md

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


用ResNet做图像分类

这个例子中,我们将Torch训练好的ResNet转换为SINGA模型以用作图像分类。

操作说明

  • 下载参数的checkpoint文件到如下目录

      $ 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
    
  • 运行程序

      $ python serve.py -h
    
  • 运行程序

      # use cpu
      $ python serve.py --use_cpu --parameter_file resnet-18.pickle --model resnet --depth 18 &
      # use gpu
      $ python serve.py --parameter_file resnet-18.pickle --model resnet --depth 18 &
    

    我们提供了以下模型和深度配置的参数文件:

    • resnet (原始 resnet), 18|34|101|152
    • 包括批量正则, 50
    • wrn (宽 resnet), 50
    • preact (包括 pre-activation 的 resnet) 200
  • 提交图片进行分类

      $ 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和image3.jpg应该在执行指令前就已被下载。

详细信息

convert.py从torch参数文件中提取参数值

  • 运行程序

      $ python convert.py -h