MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / export_onnx_model

Function export_onnx_model

detectron2/export/api.py:165–184  ·  view source on GitHub ↗

Export a detectron2 model to ONNX format. Note that the exported model contains custom ops only available in caffe2, therefore it cannot be directly executed by other runtime. Post-processing or transformation passes may be applied on the model to accommodate different runtimes, but

(cfg, model, inputs)

Source from the content-addressed store, hash-verified

163
164
165def export_onnx_model(cfg, model, inputs):
166 """
167 Export a detectron2 model to ONNX format.
168 Note that the exported model contains custom ops only available in caffe2, therefore it
169 cannot be directly executed by other runtime. Post-processing or transformation passes
170 may be applied on the model to accommodate different runtimes, but we currently do not
171 provide support for them.
172
173 Args:
174 cfg (CfgNode): a detectron2 config, with extra export-related options
175 added by :func:`add_export_config`.
176 model (nn.Module): a model built by
177 :func:`detectron2.modeling.build_model`.
178 It will be modified by this function.
179 inputs: sample inputs that the given model takes for inference.
180 Will be used to trace the model.
181 Returns:
182 onnx.ModelProto: an onnx model.
183 """
184 return Caffe2Tracer(cfg, model, inputs).export_onnx()
185
186
187class Caffe2Model(nn.Module):

Callers

nothing calls this directly

Calls 2

Caffe2TracerClass · 0.85
export_onnxMethod · 0.80

Tested by

no test coverage detected