项目作者: inisis

项目描述 :
pytorch 2 caffe
高级语言: Python
项目地址: git://github.com/inisis/brocolli.git
创建时间: 2019-02-01T17:17:22Z
项目社区:https://github.com/inisis/brocolli

开源协议:

下载


brocolli (Deprecated, this repo is no longer maintained)

torch fx based pytorch model converter, including pytorch2caffe, pytorch2onnx.
torch fx based pytorch model quantizier.

Installation

  1. pip install brocolli

How to use

  • torch2caffe

    • caffe installation

      1. pip install brocolli-caffe
      1. import torchvision.models as models
      2. from brocolli.converter.pytorch_caffe_parser import PytorchCaffeParser
      3. net = models.alexnet(pretrained=False)
      4. x = torch.rand(1, 3, 224, 224)
      5. pytorch_parser = PytorchCaffeParser(net, x)
      6. pytorch_parser.convert()
      7. pytorch_parser.save('alexnet')

      run this script until you see “accuracy test passed” on screen, then you can get alexnet.caffemodel and alexnet.prototxt under under current folder.

  • torch2onnx

    1. import torchvision.models as models
    2. from brocolli.converter.pytorch_onnx_parser import PytorchOnnxParser
    3. net = models.alexnet(pretrained=False)
    4. x = torch.rand(1, 3, 224, 224)
    5. pytorch_parser = PytorchOnnxParser(net, x)
    6. pytorch_parser.convert()
    7. pytorch_parser.save('alexnet.onnx')

    run this script until you see “accuracy test passed” on screen, then you can get alexnet.onnx under current folder.

Contact

QQ Group: 597059928

image

Show your support

Give a 🌟 if this project helpes~