onnx use pixel_values = np.random.rand(0, 3, 512, 512).astype(np.float32) will cause onnx warning

#15
by xxai-art - opened

I saw in this discussion https://huggingface.co/jinaai/jina-clip-v2/discussions/12

that using pixel_values = np.random.rand(0, 3, 512, 512).astype(np.float32) can skip computing image vectors and only compute text vectors. However, this approach triggers many warnings. How can I avoid these warnings?

CleanShot 2024-12-02 at 12.58.17.png


❯ ./main.py
2024-12-02 12:59:46.183221 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1024} != {0,1024}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
2024-12-02 12:59:46.183253 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1024} != {0,1024}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
2024-12-02 12:59:46.183259 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1} != {0,1}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
2024-12-02 12:59:46.183265 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1} != {0,1}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
2024-12-02 12:59:46.183302 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1} != {0,1}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
2024-12-02 12:59:46.183310 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1024} != {0,1024}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
2024-12-02 12:59:46.183317 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1024} != {0,1024}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
2024-12-02 12:59:46.183408 [W:onnxruntime:, execution_frame.cc:651 AllocateMLValueTensorPreAllocateBuffer] Shape mismatch attempting to re-use buffer. {2,1024} != {0,1024}. Validate usage of dim_value (values should be > 0) and dim_param (all values with the same string should equate to the same size) in shapes in the model.
text_embeddings [[ 0.01912099  0.0926741  -0.07058127 ...  0.00949061 -0.00961232
  -0.00106417]
 [ 0.02101001  0.06672169 -0.07842559 ...  0.0237933  -0.01988332
   0.01268288]]
image_embeddings []

Hey, you can silence the warnings with https://onnxruntime.ai/docs/api/python/api_summary.html#onnxruntime.set_default_logger_severity. @Xenova anything we can do on the model side?

This appears to be a bug in onnxruntime, since the model is a valid ONNX model. Related: https://github.com/microsoft/onnxruntime-genai/issues/1098

Might be worth opening a separate issue though.

Hey, you can silence the warnings with https://onnxruntime.ai/docs/api/python/api_summary.html#onnxruntime.set_default_logger_severity. @Xenova anything we can do on the model side?

I think it can be divided into 2 onnx, one for pictures and one for text

Sign up or log in to comment