GoogleCloudPlatform / generative-ai

Sample code and notebooks for Generative AI on Google Cloud, with Gemini on Vertex AI
https://cloud.google.com/vertex-ai/docs/generative-ai/learn/overview
Apache License 2.0
6.37k stars 1.66k forks source link

'bytes' object has no attribute 'save' #339

Closed nwipfli closed 5 months ago

nwipfli commented 6 months ago

When running the notebook Multimodal Retrieval Augmented Generation (RAG) using Vertex AI Gemini API I'm getting the following error for the utils intro_multimodal_rag_utils.py when the function "get_document_metadata" is executed.

/content/utils/intro_multimodal_rag_utils.py in get_document_metadata(project_id, generative_multimodal_model, pdf_path, image_save_dir, image_description_prompt, embedding_size, text_emb_text_limit) 562 image_metadata[page_num][image_number] = {} 563 --> 564 image_for_gemini, image_name = get_image_for_gemini( 565 doc, image, image_no, image_save_dir, file_name, page_num 566 )

/content/utils/intro_multimodal_rag_utils.py in get_image_for_gemini(doc, image, image_no, image_save_dir, file_name, page_num) 382 383 # Save the image to the specified location --> 384 data.save(image_name) 385 386 # Load the saved image as a Gemini Image Object

AttributeError: 'bytes' object has no attribute 'save'

isidor131908 commented 6 months ago

I have the same problem..

yosephfernando commented 6 months ago

Same here! Was working perfectly yesterday though.

lavinigam-gcp commented 6 months ago

Fixed: https://github.com/GoogleCloudPlatform/generative-ai/pull/343

Note: We are reverting to older (pre-linting) version for the intro_multimodal_rag_utils.py for the time-being to unblock a few issues. However, we are working on fixing the lint issues that broke the notebook and push the tested version next week.

nwipfli commented 6 months ago

I have just tested and it works. Excellent, thanks a lot.