LayoutLMv3 Onnx Conversion
Apologies for missing something very obvious but I am just getting started with ONNX and don’t understand many of the errors and problems leading upto converting finetuned local models to ONNX format.Currently trying to export a finetuned model oflayoutlmv3-base, however I encounter a similar error as mentioned above in thispost #23166x----------------------------------Configuration Details----------------------------------xtransformers = 4.28.1Python = 3.8.10torch = 1.12.0onnx = 1.13.1CPU Onlyx----------------------------------Error Trace----------------------------------xLocal PyTorch model found.Framework not requested. Using torch to export to ONNX.Using framework PyTorch: 1.12.0+cu102Traceback (most recent call last):File “/usr/lib/python3.8/runpy.py”, line 194, in _run_module_as_mainreturn _run_code(code, main_globals, None,File “/usr/lib/python3.8/runpy.py”, line 87, in _run_codeexec(code, run_globals)File “/usr/local/lib/python3.8/dist-packages/transformers/onnx/main.py”, line 240, inmain()File “/usr/local/lib/python3.8/dist-packages/transformers/onnx/main.py”, line 232, in mainexport_with_transformers(args)File “/usr/local/lib/python3.8/dist-packages/transformers/onnx/main.py”, line 165, in export_with_transformersonnx_inputs, onnx_outputs = export(File “/usr/local/lib/python3.8/dist-packages/transformers/onnx/convert.py”, line 346, in exportreturn export_pytorch(preprocessor, model, config, opset, output, tokenizer=tokenizer, device=device)File “/usr/local/lib/python3.8/dist-packages/transformers/onnx/convert.py”, line 143, in export_pytorchmodel_inputs = config.generate_dummy_inputs(preprocessor, framework=TensorType.PYTORCH)File “/usr/local/lib/python3.8/dist-packages/transformers/models/layoutlmv3/configuration_layoutlmv3.py”, line 263, in generate_dummy_inputssetattr(processor.feature_extractor, “apply_ocr”, False)AttributeError: ‘LayoutLMv3TokenizerFast’ object has no attribute ‘feature_extractor’Am I missing something very obvious?
2023-04-20T12:01:21Z
This issue is solved by using the recommendedoptimum.exporters.onnxthe details of using this library for exporting can be found at the followingOptimum Link