(self, text, verbose=False)
| 125 | self.model = load_model(Path(self.model_path) / model_name) |
| 126 | |
| 127 | def predict(self, text, verbose=False): |
| 128 | # Inputs are provided through numpy array |
| 129 | model_inputs = self.tokenizer(text, return_tensors="pt") |
| 130 | inputs_onnx = {k: v.cpu().detach().numpy() for k, v in model_inputs.items()} |
| 131 | outputs = self.model.run(None, inputs_onnx) |
| 132 | softmax_preds = softmax(outputs[0]) |
| 133 | preds = list(zip(self.labels, softmax_preds[0])) |
| 134 | return sorted(preds, key=lambda x: x[1], reverse=True) |
| 135 | |
| 136 | |
| 137 |