Converts the torch model into an onnx model. Args: output_fpath (str): File location of the generated ONNX file. converter (ModelFileConverter): Class to convert current model instance into another. force_overwrite (bool): If the file already exi
(
self,
output_fpath: str,
converter: ModelFileConverter = None,
force_overwrite: bool = False,
)
| 297 | return load(self.fpath) |
| 298 | |
| 299 | def as_onnx_model( |
| 300 | self, |
| 301 | output_fpath: str, |
| 302 | converter: ModelFileConverter = None, |
| 303 | force_overwrite: bool = False, |
| 304 | ): |
| 305 | """ |
| 306 | Converts the torch model into an onnx model. |
| 307 | |
| 308 | Args: |
| 309 | output_fpath (str): File location of the generated ONNX file. |
| 310 | converter (ModelFileConverter): Class to convert current model instance into another. |
| 311 | force_overwrite (bool): If the file already exists, tell whether or not to overwrite. |
| 312 | Since torch models folders, can potentially erase entire folders. |
| 313 | Return: |
| 314 | (converter.onnx_class): Returns a converted instance of ONNXModelFile. |
| 315 | """ |
| 316 | converter = self.default_converter if converter is None else converter() |
| 317 | if not force_overwrite and os.path.exists(output_fpath): |
| 318 | return converter.onnx_class(output_fpath, self.network_metadata) |
| 319 | |
| 320 | return converter.torch_to_onnx( |
| 321 | output_fpath, self.load_model(), self.network_metadata |
| 322 | ) |
| 323 | |
| 324 | def as_torch_model( |
| 325 | self, |
nothing calls this directly
no test coverage detected