You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My collaborators and I are trying to use your very useful containers to deploy and use Google's PaliGemma models on GCS/Vertex. I was wondering what is the best way to query the model with images, especially if the images are stored locally? I see that there is an example showing this for Llama Vision but it seems like you have to pass in the images as urls which may not be feasible for us..
We're getting some success by doing something like this, but unsure if that's the right way:
image_path="/PATH/rabbit.png"withopen(image_path, "rb") asf:
image=base64.b64encode(f.read()).decode("utf-8")
image=f"data:image/png;base64,{image}"output=deployed_model.predict(
instances=[
{
"inputs":f"![]({image})What is the animal wearing?",
"parameters":{"max_new_tokens": 100, "do_sample": False}
}
]
)
#> space suit
Please let me know if you need more details! Any assistance would be much appreciated!
The text was updated successfully, but these errors were encountered:
Here's the full example as shown in the documentation linked above:
importbase64fromhuggingface_hubimportInferenceClientclient=InferenceClient("http://127.0.0.1:8080")
image_path="rabbit.png"withopen(image_path, "rb") asf:
image=base64.b64encode(f.read()).decode("utf-8")
image=f"data:image/png;base64,{image}"prompt=f"![]({image})What is this a picture of?\n\n"fortokeninclient.text_generation(prompt, max_new_tokens=10, stream=True):
print(token)
I'll try to create an example within this repository too in order to have a working example with the different alternatives!
P.S. just realised that you are missing the two ending line-breaks i.e. \n, and Paligemma is known to be quite sensitive to the prompt formatting, so your code should look like the following instead:
image_path="/PATH/rabbit.png"withopen(image_path, "rb") asf:
image=base64.b64encode(f.read()).decode("utf-8")
image=f"data:image/png;base64,{image}"output=deployed_model.predict(
instances=[
{
"inputs":f"![]({image})What is the animal wearing?\n\n",
"parameters":{"max_new_tokens": 100, "do_sample": False}
}
]
)
#> space suit
My collaborators and I are trying to use your very useful containers to deploy and use Google's PaliGemma models on GCS/Vertex. I was wondering what is the best way to query the model with images, especially if the images are stored locally? I see that there is an example showing this for Llama Vision but it seems like you have to pass in the images as urls which may not be feasible for us..
We're getting some success by doing something like this, but unsure if that's the right way:
Please let me know if you need more details! Any assistance would be much appreciated!
The text was updated successfully, but these errors were encountered: