- Newest
- Most votes
- Most comments
The Llama 3.2 90B Vision model in Amazon Bedrock currently supports PNG format for image inputs, but not JPEG. This is why your code works with PNG files but fails with JPEG files.
When you specify "format": "png" in your message structure, you're telling the model to expect a PNG image. The model then successfully processes the PNG file you provide. However, when you change this to "format": "jpeg" and provide a JPEG file, the model encounters an error because it's not designed to handle JPEG inputs.
To use your JPEG image with this model, you would need to convert it to PNG format before sending it to the Bedrock Converse API. You can use a library like Pillow (PIL) in Python to perform this conversion.
Here's how you could modify your code to convert a JPEG to PNG before sending it to the model:
from PIL import Image import io # Load JPEG image jpeg_image = Image.open("example.jpg") # Convert to PNG png_buffer = io.BytesIO() jpeg_image.save(png_buffer, format="PNG") png_bytes = png_buffer.getvalue() # Use png_bytes in your messages structure messages = [ { "role": "user", "content": [ {"text": "Describe image"}, { "image": { "format": "png", "source": {"bytes": png_bytes}, } }, ], } ]
This approach allows you to use JPEG images with the Llama 3.2 90B Vision model by converting them to PNG format before sending them to the API. Remember to keep the "format": "png" in your message structure, as the model expects PNG input.
Sources
Introducing Llama 3.2 models from Meta in Amazon Bedrock: A new generation of multimodal vision and lightweight models | AWS News Blog
Vision use cases with Llama 3.2 11B and 90B models from Meta | AWS Machine Learning Blog
Relevant content
asked 2 years ago

Why is something like this not included in the documentation or mentioned anywhere?