Loads the model from disk if isn't already loaded. Does not attempt to load if given model is already loaded and instead returns original instance. Use as_torch_model() instead to always guarantee a new instance and location on disk. Args: None
(self)
| 280 | self.model = None |
| 281 | |
| 282 | def load_model(self) -> Module: |
| 283 | """ |
| 284 | Loads the model from disk if isn't already loaded. |
| 285 | Does not attempt to load if given model is already loaded and instead returns original instance. |
| 286 | Use as_torch_model() instead to always guarantee a new instance and location on disk. |
| 287 | |
| 288 | Args: |
| 289 | None |
| 290 | |
| 291 | Returns: |
| 292 | torch.Model: Loaded torch model. |
| 293 | """ |
| 294 | if self.is_loaded: |
| 295 | return self.model |
| 296 | |
| 297 | return load(self.fpath) |
| 298 | |
| 299 | def as_onnx_model( |
| 300 | self, |