|
74 | 74 | logging.basicConfig(level=logging.WARNING, format=FORMAT) |
75 | 75 |
|
76 | 76 |
|
77 | | -def _load_example_inputs(model_input: str | None) -> Any: |
| 77 | +def _load_example_inputs(model_input: str | None) -> Any: # nosec B614 |
78 | 78 | """Load example inputs from a `.pt` file when a path is provided.""" |
79 | 79 | if model_input is None: |
80 | 80 | return None |
81 | 81 |
|
82 | 82 | logging.info(f"Load model input from {model_input}") |
83 | 83 |
|
84 | 84 | if model_input.endswith(".pt"): |
85 | | - return torch.load(model_input, weights_only=False) |
| 85 | + return torch.load( |
| 86 | + model_input, weights_only=False |
| 87 | + ) # nosec B614 trusted artifacts |
86 | 88 |
|
87 | 89 | raise RuntimeError( |
88 | 90 | f"Model input data '{model_input}' is not a valid name. Use --model_input " |
@@ -167,14 +169,14 @@ def _load_python_module_model( |
167 | 169 |
|
168 | 170 | def _load_serialized_model( |
169 | 171 | model_name: str, example_inputs: Any |
170 | | -) -> Optional[Tuple[torch.nn.Module, Any]]: |
| 172 | +) -> Optional[Tuple[torch.nn.Module, Any]]: # nosec B614 |
171 | 173 | """Load a serialized Torch model saved via `torch.save`.""" |
172 | 174 | if not model_name.endswith((".pth", ".pt")): |
173 | 175 | return None |
174 | 176 |
|
175 | 177 | logging.info(f"Load model file {model_name}") |
176 | 178 |
|
177 | | - model = torch.load(model_name, weights_only=False) |
| 179 | + model = torch.load(model_name, weights_only=False) # nosec B614 trusted inputs |
178 | 180 | if example_inputs is None: |
179 | 181 | raise RuntimeError( |
180 | 182 | f"Model '{model_name}' requires input data specify --model_input <FILE>.pt" |
|
0 commit comments