Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Caffe2 Quick Start Guide

You're reading from  Caffe2 Quick Start Guide

Product type Book
Published in May 2019
Publisher Packt
ISBN-13 9781789137750
Pages 136 pages
Edition 1st Edition
Languages
Author (1):
Ashwin Nanjappa Ashwin Nanjappa
Profile icon Ashwin Nanjappa

Using the ONNX model in Caffe2

In the previous section, we converted a Caffe2 model to ONNX format so that it could be used with other DL frameworks. In this section, we will learn how to use an ONNX model exported from other DL frameworks into Caffe2 for inference.

The backend module provided in the Caffe2 ONNX package enables this import of the ONNX model to Caffe2. This can be seen in the backend.py file in the python/onnx directory in the Caffe2 source code.

The ch5/run_onnx_model.py script provided along with this book's source code demonstrates how to load an ONNX model to Caffe2, and run an inference on an input image using that model.

The script first imports the Python modules necessary to work with the images (PIL.Image), Caffe2, and ONNX (caffe2.python.onnx.backend) as follows:

# Std
import PIL.Image
import json
import sys

# Ext
import numpy as np
from caffe2...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}