File size: 772 Bytes
6780cf2
69b7d56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6780cf2
69b7d56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import cv2
from PIL import Image
import PIL.PngImagePlugin
import google.generativeai as genai

# Initialize the GenerativeModel
genai.configure(api_key='AIzaSyDpsP6LqSShjygGU_P6t0Hex7wn320XGxw')
model = genai.GenerativeModel('gemini-pro-vision')

def process_frames(prompt, img):
    frame_pil = Image.fromarray(img)
    response = model.generate_content([prompt, frame_pil])
    return response.text

iface = gr.Interface(fn=process_frames,
                     inputs=["text", "image"],
                     outputs="text",
                     title="Gemini Pro Vision Demo",
                     description="Enter a prompt and view the generated content.",
                     allow_flagging=False)
if __name__ == "__main__":
    iface.launch()