Convert to ONNX

#5
by robert1602 - opened

I am trying to convert Blip2 to ONNX, I know it's not yet supported for the 'easiest' way to do this, so I was trying the low-level option, but I got this error:

File "/usr/local/lib/python3.9/dist-packages/transformers/models/t5/modeling_t5.py", line 981, in forward
raise ValueError(f"You have to specify either {err_msg_prefix}input_ids or {err_msg_prefix}inputs_embeds")

This is the code I use:

torch.onnx.export(MODEL,
tuple(DUMMY_MODEL_INPUT.values()),
"{}.onnx".format(MODEL_NAME),
verbose=True,
input_names=['pixel_values', 'input_ids', 'attention_mask'],
output_names=['logits'],
dynamic_axes={
'input_ids': {0: 'batch_size', 1: 'sequence'},
'attention_mask': {0: 'batch_size', 1: 'sequence'},
'logits': {0: 'batch_size', 1: 'sequence'}},
do_constant_folding=True,
opset_version=13,
)

Sign up or log in to comment