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)
| 163 | |
| 164 | |
| 165 | def 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 | |
| 187 | class Caffe2Model(nn.Module): |
nothing calls this directly
no test coverage detected