NetExternalObject

NetExternalObject[]

represents a net model in an external framework format.

NetExternalObject[source]

creates a external net from source.

Details

  • NetExternalObject is typically used to run inference using neural network models not defined in the Wolfram Language.
  • Possible values for source are:
  • File["file"] or "file"file name, searched for on $Path
    URL["url"] or "url"HTTP, HTTPS or FTP URL
    "!prog"import data from a pipe
    CloudObject[]a cloud object
    LocalObject[]a local object
  • Supported file formats are:
  • "ONNX"ONNX models
    "MXNet"MXNet models
  • For a model with a single input port, NetExternalObject[][data] gives the result of applying the model to data.
  • For a model with multiple input ports, NetExternalObject[][<|port1data1,|>] provides datai to porti.
  • When data is given as NumericArray, the output will be a NumericArray. »
  • Information[NetExternalObject[]] generates an information panel about the model. »
  • Information of a NetExternalObject may include the following properties:
  • "Format"the evaluation back end used by the model
    "InputPortNames"list of names of input ports
    "InputPorts"association of input port shapes
    "LayersCount"total number of layers
    "LayerTypeCounts"how many times each type of layer occurs in the network
    "OutputPortNames"list of names of output ports
    "OutputPorts"association of output port shapes
    "Properties"available properties
    "RawData"unprocessed native contents of the model
  • NetExternalObject[][data,opts] specifies that options should be used in applying the net to data. Possible options include:
  • TargetDevice"CPU"the device on which to perform evaluation

Examples

open allclose all

Basic Examples  (2)

Import an ONNX model as an external network:

Evaluate the model on some input data:

Import a quantized image classifier:

Define a minimal pipeline to pre- and post-process the data:

Run the external model:

Scope  (4)

Formats  (2)

Import an ONNX model as a NetExternalObject:

Import an MXNet model as a NetExternalObject:

Properties  (2)

Extract a property of the external net using Information:

Get a list of properties:

Get a list of all the supported properties:

Applications  (1)

Run a real-time face detector:

Define a transformation from an image to a list of arrays:

Run the detector on the encoded image:

Extract the bounding box and probability information from the result:

Visualize the detections, filtering the ones with low probability or large overlap:

This network can analyze more that 40 images per second on a consumer laptop:

Properties & Relations  (2)

Input given as a NumericArray will cause the output to also be a NumericArray:

External net models typically have a hard-coded batch dimension:

Ordinary networks do not have an explicit batch dimension:

They work both on single examples and batches of any size:

Possible Issues  (2)

External models cannot be modified:

External models cannot be retrained:

Wolfram Research (2022), NetExternalObject, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExternalObject.html (updated 2023).

Text

Wolfram Research (2022), NetExternalObject, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExternalObject.html (updated 2023).

CMS

Wolfram Language. 2022. "NetExternalObject." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/NetExternalObject.html.

APA

Wolfram Language. (2022). NetExternalObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetExternalObject.html

BibTeX

@misc{reference.wolfram_2023_netexternalobject, author="Wolfram Research", title="{NetExternalObject}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/NetExternalObject.html}", note=[Accessed: 01-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_netexternalobject, organization={Wolfram Research}, title={NetExternalObject}, year={2023}, url={https://reference.wolfram.com/language/ref/NetExternalObject.html}, note=[Accessed: 01-March-2024 ]}