pytorch to caffe

安装caffe, gpu版本的,可以直接通过conda安装

conda install caffe-gpu

pytorch安装:官网

conda install pytorch torchvision cuda80 -c pytorch

pytorch to caffe

这里使用一个开源的代码: pytorchtocaffe

model_def = os.path.join(caffemodel_dir, 'model.prototxt')
model_weights = os.path.join(caffemodel_dir, 'model.caffemodel')
input_name = 'ConvNdBackward1'
output_name = 'AddmmBackward348'

# pytorch net
model = torchvision.models.resnet18(False)
m = torch.load('xx.pt')
model.load_state_dict(m)
model.eval()

# random input
image = np.random.randint(0, 255, input_size)
input_data = image.astype(np.float32)

# pytorch forward
input_var = Variable(torch.from_numpy(input_data))

output_var = model(input_var)
plot_graph(output_var, os.path.join(caffemodel_dir, 'pytorch_graph'))
pytorch2caffe(input_var, output_var, model_def, model_weights)

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
PyTorch, Darknet, Caffe, and TensorFlow are all popular deep learning frameworks used for building and training neural networks. PyTorch is an open-source machine learning library that is widely used for deep learning tasks. It was developed by Facebook AI Research and is known for its ease of use and flexibility. PyTorch allows users to define and train their models using dynamic computational graphs, making it a popular choice among researchers and developers. Darknet is an open-source neural network framework that is used primarily for object detection and recognition tasks. It is written in C and CUDA and is known for its fast performance and accuracy. Darknet has been used to build popular object detection models such as YOLO (You Only Look Once). Caffe is a deep learning framework that is known for its speed and scalability. It was developed by the Berkeley Vision and Learning Center and is widely used for image and video classification tasks. Caffe has a large community of users and is often used in academic research. TensorFlow is an open-source machine learning framework developed by Google Brain. It is known for its scalability and flexibility, and is widely used for deep learning tasks such as image and speech recognition. TensorFlow provides a high-level API for building and training neural networks, making it a popular choice among developers. Each of these frameworks has its own strengths and weaknesses, and the choice of which one to use will depend on the specific task at hand and the user's preferences and experience.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值