Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Caffe2 Quick Start Guide

You're reading from   Caffe2 Quick Start Guide Modular and scalable deep learning made easy

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781789137750
Length 136 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ashwin Nanjappa Ashwin Nanjappa
Author Profile Icon Ashwin Nanjappa
Ashwin Nanjappa
Arrow right icon
View More author details
Toc

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 €18.99/month. Cancel anytime