Load example inputs from a `.pt` file when a path is provided.
(model_input: str | None)
| 84 | |
| 85 | |
| 86 | def _load_example_inputs(model_input: str | None) -> Any: # nosec B614 |
| 87 | """Load example inputs from a `.pt` file when a path is provided.""" |
| 88 | if model_input is None: |
| 89 | return None |
| 90 | |
| 91 | logging.info(f"Load model input from {model_input}") |
| 92 | |
| 93 | if model_input.endswith(".pt"): |
| 94 | return torch.load( |
| 95 | model_input, weights_only=False |
| 96 | ) # nosec B614 trusted artifacts |
| 97 | |
| 98 | raise RuntimeError( |
| 99 | f"Model input data '{model_input}' is not a valid name. Use --model_input " |
| 100 | "<FILE>.pt e.g. saved with torch.save()" |
| 101 | ) |
| 102 | |
| 103 | |
| 104 | def _load_internal_model( |
no test coverage detected