caffe2官网教程学习(二)—— 加载预训练模型

本文档详细介绍了如何在Caffe2中加载预训练的深度学习模型,包括从模型库下载模型、导入所需模块、对输入图像进行预处理、将protobufs加载到工作空间并运行网络,最终展示运行结果。
摘要由CSDN通过智能技术生成

来源地址: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 should have already converted or downloaded one.
# format below i
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值