Spaces:
Running
Running
File size: 717 Bytes
421825f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
import google.generativeai as genai
import os
from dotenv import load_dotenv
import PIL.Image
load_dotenv()
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
model = genai.GenerativeModel("gemini-pro-vision")
def process_image(img_path, prompt):
# Use the img_path directly to pass it to the model
print("Image Path:", img_path)
print("Prompt:", prompt)
img = PIL.Image.open(img_path)
response = model.generate_content([prompt, img], stream=True)
response.resolve()
return response.text
iface = gr.Interface(
fn=process_image,
inputs=[gr.Image(type="filepath"), gr.Textbox()],
outputs="text",
live=False,
)
iface.launch(share=True) |