使用工具:
https://github.com/xxradon/PytorchToCaffe
主要使用pytorch_to_caffe.py
使用例子example 中
将训练好的mobilev2_fcn 成功转成caffemodel
if __name__ == '__main__':
exit()
name = 'Anngic_lanenet'
net = fcn_mobile(11)
checkpoint = torch.load("/home/pc007/PycharmProjects/Lane_seg_anngic/params/FCN_mobilev2_end17_s=2_equal_anngic_lane_params_init.pkl")
net.load_state_dict(checkpoint)
net.eval()
input = torch.ones([1, 3, 224, 640])
# input=torch.ones([1,3,224,224])
pytorch_to_caffe.trans_net(net, input, name)
pytorch_to_caffe.save_prototxt('{}.prototxt'.format(name))
pytorch_to_caffe.save_caffemodel('{}.caffemodel'.format(name))
caffe model 可视化:caffemodel 可视化
caffemodel Python接口测试验证模型无偏差:
import caffe
from PIL import