Skip to content

Instantly share code, notes, and snippets.

@matthewchung74
Created December 23, 2022 07:37
Show Gist options
  • Save matthewchung74/f4971ca0c500c5a67b073f7dfbdfdb49 to your computer and use it in GitHub Desktop.
Save matthewchung74/f4971ca0c500c5a67b073f7dfbdfdb49 to your computer and use it in GitHub Desktop.
python -m transformers.onnx -m="microsoft/trocr-large-printed" --framework="pt" --feature="vision2seq-lm" .
Some weights of VisionEncoderDecoderModel were not initialized from the model checkpoint at microsoft/trocr-large-printed and are newly initialized: ['encoder.pooler.dense.weight', 'encoder.pooler.dense.bias']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Using framework PyTorch: 1.13.1
/Users/mattc/Desktop/onnx/venv/lib/python3.10/site-packages/transformers/models/vit/modeling_vit.py:176: 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 num_channels != self.num_channels:
/Users/mattc/Desktop/onnx/venv/lib/python3.10/site-packages/transformers/models/vit/modeling_vit.py:181: 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 height != self.image_size[0] or width != self.image_size[1]:
Validating ONNX model...
-[✓] ONNX model output names match reference model ({'last_hidden_state'})
- Validating ONNX Model output "last_hidden_state":
-[✓] (3, 577, 1024) matches (3, 577, 1024)
-[x] values not close enough (atol: 0.0001)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/mattc/Desktop/onnx/venv/lib/python3.10/site-packages/transformers/onnx/__main__.py", line 180, in <module>
main()
File "/Users/mattc/Desktop/onnx/venv/lib/python3.10/site-packages/transformers/onnx/__main__.py", line 107, in main
validate_model_outputs(
File "/Users/mattc/Desktop/onnx/venv/lib/python3.10/site-packages/transformers/onnx/convert.py", line 472, in validate_model_outputs
raise ValueError(
ValueError: Outputs values doesn't match between reference model and ONNX exported model: Got max absolute difference of: 0.003101348876953125 for [ 5.296753 -1.1317961 -3.054056 ... -0.14895228 -1.1711152
0.31119758] vs [ 5.2969065 -1.1319674 -3.0543997 ... -0.14916274 -1.1713439
0.31131762]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment