Code Monkey home page Code Monkey logo

cifar10's Introduction

This is an interview project for AI engineer of a SECRET COMPANY.

Targets

  • reproduce the results of resnet on Cifar10 with pytorch.
  • convert pytorch model to caffe2 model
  • predict image with c++ project organized by cmake

Reproduce

Reproducing is easy, just implement the resnet and train it with suggested super parameters.

To evaluate the accuracy on test dataset for resnet20, just run:

git clone https://github.com/shellhue/Cifar10.git && cd Cifar10
python evaluate.py --layers=20 --weights='./weights/resnet20_164.pth'

The corresponding error is:

8.33%  (target is 8.75%)

To evaluate the accuracy on test dataset for resnet56, just run:

git clone https://github.com/shellhue/Cifar10.git && cd Cifar10
python evaluate.py --layers=56 --weights='./weights/resnet56_164.pth'

The corresponding error is:

6.83%  (target is 6.97%)

Convert to caffe2

To convert pytorch model to caffe2 model, two steps are needed.

First, convert pytorch model to onnx model:

python convert2onnx.py --layers=20 --pretrained_weights='./weights/resnet20_164.pth' // resnet20.onnx will be created

Second, convert onnx model to caffe2 model:

python onnx2pb.py --layers=20 --onnx_proto_file='pathToOnnxProtoFile' // onnx-init-20.pb and onnx-predict-20.pb will be created

Predict with c++

I haven’t finished this. But i know how to do it. Just follow caffe2_cpp_tutorial, and then change the pretrained.cc in dir /src/caffe2/binaries/ to use the onnx-init-20.pb onnx-predict-20.pb files. Unfortunately, it is hard to make caffe2_cpp_tutorialrun. I find that installing caffe by building the source is needed, but the installation is very slow. And i have no time!!

cifar10's People

Contributors

shellhue avatar

Stargazers

rohit sohlot avatar Robin van Emden avatar Valentino Peluso avatar  avatar gzhawk avatar

Watchers

 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.