Spaces:
Runtime error
Runtime error
import streamlit as st | |
import google.generativeai as genAi | |
from PIL import Image | |
# Configure API key | |
genAi.configure(api_key="AIzaSyBZQmot8_8bDxuGiffJ06woJCzH140Erc4") | |
def get_response(inputt, image): | |
model = genAi.GenerativeModel('gemini-pro-vision') | |
if inputt != "": | |
response = model.generate_content([inputt, image]) | |
else: | |
response = model.generate_content(image) | |
return response.text | |
# Streamlit app header and user inputs | |
st.header("PROJECT") | |
inputt = st.text_input("Input Prompt", key='inputt') | |
upload_file = st.file_uploader("Choose your file", type=['jpg', 'jpeg', 'png']) | |
image = '' | |
if upload_file is not None: | |
image = Image.open(upload_file) | |
st.image(image, caption="Uploaded Image", use_column_width=True) | |
# Button to trigger content generation | |
submit = st.button("ASK") | |
if submit: | |
response = get_response(inputt, image) | |
st.write(response) | |