Find answers from the community

Updated 4 months ago

LlamaIndex + Gemini

At a glance
The community member is trying to use the Gemini library from LlamaIndex to process images, but the provided code example uses image URLs, while the community member has images stored locally on their computer. A fellow community member suggests using the SimpleDirectoryReader to load images from a local folder, which appears to be the answer to the community member's question.
Useful resources
Hi Friends,
I am trying to use gemini by following this tutorial https://blog.llamaindex.ai/llamaindex-gemini-8d7c3b9ea97e

The code example shows that it takes some pictures from the internet by putting urls. Since I have my pictures in my local computer, does LlamaIndex have a function that can load image from local computer ?

Here is the code example in that tutorial :

from llama_index.multi_modal_llms.gemini import GeminiMultiModal
from llama_index.multi_modal_llms.generic_utils import (
load_image_urls,
)

image_urls = [
"",
# Add yours here!
]
image_documents = load_image_urls(image_urls)
gemini_pro = GeminiMultiModal(model="models/gemini-pro")
complete_response = gemini_pro.complete(
prompt="Identify the city where this photo was taken.",
image_documents=image_documents,
)
L
i
2 comments
Just use SimpleDirectoryReader and point it at your folder of images

image_documents = SimpleDirectoryReader("./folder_of_images").load_data()
Thanks a lot @Logan M
Add a reply
Sign up and join the conversation on Discord