Coder Social home page Coder Social logo

caffe_to_torch_to_pytorch's Introduction

Convert caffe to pytorch

Convert caffe to torch

Convert torch to pytorch

  • Convert caffe model to pytorch model
  • Convert caffe model to torch model
  • Convert torch model to pytorch model
  • I have tested on vgg16, it behaves well on classification tasks. But I can't guarantee it performs well on other tasks(such as object detection and semantic segmentation). You can try it and modify the code according the bug info. If there are new components in your caffe model, you should add corresponding parts in the code。

Install torch

install loadcaffe

Convert caffe to torch

  • Change the path to your own path.

  • Put the .prototxt and .caffemodel file in the same folder.

  • You will get the vgg16_torch.t7 file.

th caffemodel_to_t7.lua

Convert torch to pytorch

python convert_torch.py -m vgg16_torch.t7

Two file will be created vgg16_torch.py vgg16_torch.pth

Load the .pth model in python

  • Make sure the vgg16_torch.py and vgg16_torch.pth files in the same folder with the python workspace.
  • The import vgg16_torch means importing the model structure from the vgg16_torch.py.
  • The model.load_state_dict means loading weights from vgg16_torch.pth into the model structure.
import vgg16_torch

model = vgg16_torch.vgg16_torch
model.load_state_dict(torch.load('vgg16_torch.pth'))
model.eval()
...

Acknowledgement

caffe_to_torch_to_pytorch's People

Contributors

fanq15 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.