Spaces:
Sleeping
Sleeping
File size: 784 Bytes
337a0be |
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 |
import google.generativeai as genai
import gradio as gr
import numpy as np
import PIL.Image
genai.configure(api_key="AIzaSyA7tPavobVN5_3-BJ0qhFT5HVjO4V19QWk")
def ImageChat(image, prompt):
# load model
model = genai.GenerativeModel("gemini-1.5-flash")
# check image file and convert to a Numpy array
if isinstance(image, np.ndarray):
img = PIL.Image.fromarray(image)
else:
img = PIL.Image.open(image)
response = model.generate_content([prompt, img])
return response.text
app = gr.Interface(ImageChat,
inputs = [gr.Image(label = "Image"), gr.Text(label = "Prompt")],
outputs = gr.Text(label = "Response"),
title = "Image Chat",
theme = "Taithrah/Minimal")
app.launch() |