来源地址:https://caffe2.ai/docs/tutorial-loading-pre-trained-models.html
1.下载模型
模型库:https://github.com/caffe2/models
#squeezenet为模型名称
python -m caffe2.python.models.download -i squeezenet
或者用Git克隆
git clone https://github.com/caffe2/models
2.导入模块
# where you installed caffe2. Probably '~/pytorch' or '~/src/pytorch'.
CAFFE2_ROOT = "~/pytorch"
# assumes being a subdirectory of caffe2
CAFFE_MODELS = "~/pytorch/caffe2/python/models"
# if you have a mean file, place it in the same dir as the model
%matplotlib inline
from caffe2.proto import caffe2_pb2
import numpy as np
import skimage.io
import skimage.transform
from matplotlib import pyplot
import os
from caffe2.python import core, workspace
import urllib2
print("Required modules imported.")
3.图像传输
其中code是AlexNet object codes
IMAGE_LOCATION = "https://cdn.pixabay.com/photo/2015/02/10/21/28/flower-631765_1280.jpg"
# What model are we using? You shoul