Closed Quang-elec44 closed 4 months ago
Hi @Quang-elec44, this script was designed to convert the pre-trained model saved with the new codebase. In the current version of GLiNER, it saves the tokenizer, so this is why you need to set load_tokenizer=True
. To convert to ONNX old GLiNER models, please, refer to this notebook https://github.com/urchade/GLiNER/blob/main/examples/convert_to_onnx.ipynb. If you will encounter any bugs, feel free to let me know!
Hi @Quang-elec44, this script was designed to convert the pre-trained model saved with the new codebase. In the current version of GLiNER, it saves the tokenizer, so this is why you need to set
load_tokenizer=True
. To convert to ONNX old GLiNER models, please, refer to this notebook https://github.com/urchade/GLiNER/blob/main/examples/convert_to_onnx.ipynb. If you will encounter any bugs, feel free to let me know!
Hi. I have the same problem and try to use your notebook for convert gliner_medium to onnx. I didn't change default notebook and I have warnings and error. I run cell with it:
...
print('Converting the model...')
torch.onnx.export(
gliner_model.model,
all_inputs,
f=onnx_save_path,
input_names=input_names,
output_names=["logits"],
dynamic_axes=dynamic_axes,
opset_version=14,
)
and it print warnings:
Converting the model...
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:547](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:547): TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
torch.tensor(mid - 1).type_as(relative_pos),
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:551](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:551): TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
torch.ceil(torch.log(abs_pos [/](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/) mid) [/](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/) torch.log(torch.tensor((max_position - 1) [/](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/) mid)) * (mid - 1)) + mid
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:710](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:710): TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
scale = torch.sqrt(torch.tensor(query_layer.size(-1), dtype=torch.float) * scale_factor)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:710](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:710): UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
scale = torch.sqrt(torch.tensor(query_layer.size(-1), dtype=torch.float) * scale_factor)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:785](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:785): TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
scale = torch.sqrt(torch.tensor(pos_key_layer.size(-1), dtype=torch.float) * scale_factor)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:785](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:785): UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
scale = torch.sqrt(torch.tensor(pos_key_layer.size(-1), dtype=torch.float) * scale_factor)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:797](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:797): TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
scale = torch.sqrt(torch.tensor(pos_query_layer.size(-1), dtype=torch.float) * scale_factor)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:797](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:797): UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
scale = torch.sqrt(torch.tensor(pos_query_layer.size(-1), dtype=torch.float) * scale_factor)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:798](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:798): TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if key_layer.size(-2) != query_layer.size(-2):
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:105](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:105): TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
output = input.masked_fill(rmask, torch.tensor(torch.finfo(input.dtype).min))
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/modeling/base.py:35](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/modeling/base.py:35): TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
max_text_length = text_lengths.max().item()
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/modeling/base.py:36](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/modeling/base.py:36): TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
max_length = max(max_embed_dim, max_text_length)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/torch/onnx/symbolic_opset9.py:5858](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/torch/onnx/symbolic_opset9.py:5858): UserWarning: Exporting aten::index operator of advanced indexing in opset 14 is achieved by combination of multiple ONNX operators, including Reshape, Transpose, Concat, and Gather. If indices include negative values, the exported graph will produce incorrect results.
warnings.warn(
[W shape_type_inference.cpp:1968] Warning: The shape inference of prim::PackPadded type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (function UpdateReliable)
[W shape_type_inference.cpp:1968] Warning: The shape inference of prim::PackPadded type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (function UpdateReliable)
[/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/torch/onnx/symbolic_opset9.py:4661](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/torch/onnx/symbolic_opset9.py:4661): UserWarning: Exporting a model to ONNX with a batch_size other than 1, with a variable length with LSTM can cause an error when running the ONNX model with a different batch size. Make sure to save the model with a batch size of 1, or define the initial states (h0/c0) as inputs of the model.
warnings.warn(
[W shape_type_inference.cpp:1968] Warning: The shape inference of prim::PadPacked type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (function UpdateReliable)
After I try to load and use converted model:
text = """
Libretto by Marius Petipa, based on the 1822 novella ``Trilby, ou Le Lutin d'Argail`` by Charles Nodier, first presented by the Ballet of the Moscow Imperial Bolshoi Theatre on January 25/February 6 (Julian/Gregorian calendar dates), 1870, in Moscow with Polina Karpakova as Trilby and Ludiia Geiten as Miranda and restaged by Petipa for the Imperial Ballet at the Imperial Bolshoi Kamenny Theatre on January 17–29, 1871 in St. Petersburg with Adèle Grantzow as Trilby and Lev Ivanov as Count Leopold.
"""
labels = ["person", "book", "location", "date", "actor", "character"]
entities = model.predict_entities(text, labels, threshold=0.4)
for entity in entities:
print(entity["text"], "=>", entity["label"])
This code print error:
...
File ~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:87, in SpanORTModel.forward(self, input_ids, attention_mask, words_mask, text_lengths, span_idx, span_mask, **kwargs)
[78](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:78) inputs = {
[79](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:79) 'input_ids': input_ids,
[80](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:80) 'attention_mask': attention_mask,
(...)
[84](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:84) 'span_mask': span_mask
[85](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:85) }
[86](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:86) prepared_inputs = self.prepare_inputs(inputs)
---> [87](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:87) inference_output = self.run_inference(prepared_inputs)
[88](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:88) outputs = GLiNERModelOutput(
[89](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:89) logits=inference_output['logits']
[90](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:90) )
[91](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:91) return outputs
File ~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:47, in BaseORTModel.run_inference(self, inputs)
[37](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:37) def run_inference(self, inputs: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
[38](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:38) """
[39](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:39) Run the ONNX model inference.
[40](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:40)
(...)
[45](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:45) Dict[str, np.ndarray]: Model's outputs as numpy arrays.
[46](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:46) """
---> [47](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:47) onnx_outputs = self.session.run(None, inputs)
[48](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:48) outputs = {name: onnx_outputs[idx] for name, idx in self.output_names.items()}
[49](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/gliner/onnx/model.py:49) return outputs
File ~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:220, in Session.run(self, output_names, input_feed, run_options)
[218](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:218) output_names = [output.name for output in self._outputs_meta]
[219](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:219) try:
--> [220](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:220) return self._sess.run(output_names, input_feed, run_options)
[221](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:221) except C.EPFail as err:
[222](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a223139322e3136382e3130332e313530222c2275736572223a22616b686f6c6b696e61227d.vscode-resource.vscode-cdn.net/home/akholkina/projects/repos/GLiNER/examples/~/projects/repos/GLiNER/venv_gliner/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:222) if self._enable_fallback:
InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Non-zero status code returned while running ScatterND node. Name:'/ScatterND_1' Status Message: invalid indice found, indice = 19
My python version is 3.11.4 and I have 0.2.6 version of GLiNER.
The checkout for version 0.2.3 helped me.
nice, v0.2.6 is available
I am having the same issue when trying to run Gliner as an huggingface endpoint on the cloud.
Hi, this line
GLiNER.from_pretrained(args.model_path, load_tokenizer=True)
in theconvert_to_onnx.py
causes an error due to noconfig.json
. I think you should change these linesin
model.py
to