Deploy ONNX Format Models
Open Neural Network Exchange or ONNX is an open standard format of machine learning models. By using the Oracle Machine Learning Services REST API, you can deploy and score your ONNX format models. The REST API is exposed as part of the Oracle Machine Learning Services on Oracle Autonomous Database cloud service.
Note:
Oracle Machine Learning Services supports ONNX Runtime 1.11.1.Supported Functions
- Storing, deleting, and listing deployed models
- Retrieving metadata and content of models
- Organizing models under namespace
- Creating, deleting, and listing model endpoints
- Getting Swagger document for the model endpoint
- Getting model details
- Getting endpoint details
- Scoring with model endpoints
Supported Machine Learning Models
- Classification models (both non-image models and image models)
- Clustering models (non-image models)
- Feature Extraction models (image models)
- Regression models (non-image models)
Prerequisites
- Create the ONNX model zip file containing the
modelName.onnx
file,metadata.json
file, andlabel.txt
(optional) file. - Ensure that the
metadata.json
file contains the following as listed in the table Contents and Description ofmetadata.json
file.
Note:
For more information about ONNX format model specifications, see Specifications for ONNX Format ModelsTable - Contents and Description of metadata.json
file
Field Name | Data Type | Description | Mandatory/Optional | Example |
---|---|---|---|---|
|
String |
The mining function of the model. It accepts the value Case-insensitive |
Mandatory |
|
|
String |
The name of the Clustering model output storing distances. For Case-sensitive |
You must specify either:
Note: You cannot specify both. |
|
|
String |
The name of the Clustering model output storing probabilities. For Case-sensitive |
You must specify either:
Note: You cannot specify both. |
|
|
String |
The name of the regression model output that stores the regression results. The output is expected to be a tensor with value type Case-sensitive |
|
|
|
String |
The name of the Classification model output storing label results. The output is expected to be a tensor. Case-sensitive |
For other cases for Classification models:
|
|
|
String |
The name of the Classification model output storing probabilities. The output is expected to be either:
Case-sensitive |
|
|
featureExtractionOutput |
String |
The name of the ONNX image model output that stores the features. The output is expected to be a tensor with value type Case-sensitive. |
|
|
For ONNX image models only |
String |
Specify what each dimension means in the input tensor. The dimension name can be Case-sensitive. Use lower case only. |
|
|
For ONNX image models only |
Integer |
Specify the image height for preprocessing. |
|
|
For ONNX image models only |
Integer |
Specify the image width for preprocessing. |
|
|
For ONNX image models only |
Integer |
Specify the image channel number for preprocessing. |
|
|
For ONNX image models only |
Float[] |
Specify the mean value for R, G, B (red, green, blue) channel for normalization. |
|
|
For ONNX image models only |
Float[] |
Specify the scale value for R, G, B (red, green, blue) channel for normalization. |
|
|
For ONNX image models only |
String |
Specify the channel order for preprocessing. Currently, only three channel images are supported. Value can be either "RGB" or "BGR". Case-insensitive. |
|
|
Scoring an ONNX Regression Model
Step 3 - Step 6 provides the steps to score an ONNX regression model.
Scoring an ONNX Image Model
Step 7 - Step 10 provides an example of deploying an ONNX image model. An image model is one that consumes image data.
You can score an ONNX image model in two ways:- By uploading a single image file as input. In this case, the equivalent tensor format of the uploaded image is generated with proper preprocessing for the model.
- By uploading a collection of scoring input records (similar to ONNX non-image models). Here, mini batch scoring with ONNX image models is done with
<model_attribute_name, value/array>
pairs. Here,value/array
can be either an encoded image in base64 string or a multidimensional array storing processed image pixel values. The supported ONNX image model must have either1
or-1
tensor batch size.
To deploy an ONNX image model: