Passing pictures as arrays to the model (Pytorch or Numpy)

#73
by artyomboyko - opened

Good day. Thanks for the model to the Google team. Thank you for supporting OpenSource.

Is there any possibility to transfer to Gemma-3-it pictures as arrays from RAM (without saving them from the disc as jpg files)? If possible, please give an example of the code. I am interested in transferring say 10 or more pictures to the model. Thanks.

Google org

Hi @artyomboyko ,

Thank you for the kind words about the Gemma 3 models and open-source support and Thanks for your interest and appreciation!

Yes, it is indeed possible to pass image data to a model like Gemma-3-it (or other similar models) directly from RAM, without saving the images as .jpg files to disk. This is typically done by keeping the images as arrays (e.g., NumPy arrays) in memory and feeding them directly into the model's input pipeline.

Kindly find this colab link for how to classify 10 images stored as byte arrays using the Gemma-3-27B-IT model from Hugging Face. let us know if you have any concerns will assist you. Thank you.

@lkv Good day. Thank you so much for the notebook. I will certainly take a look at it and come back with feedback. Need to take a little break after the MCP hackathon)

Sign up or log in to comment