Spaces:
Running
Running
import streamlit as st | |
import google.generativeai as genai | |
import os | |
from PIL import Image | |
# Configure Gemini | |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) | |
# Load Gemini multimodal model | |
model = genai.GenerativeModel("gemini-pro-vision") | |
# Streamlit UI | |
st.set_page_config(page_title="Handwritten Notes Summarizer", layout="centered") | |
st.title("π Handwritten Notes Summarizer") | |
uploaded_image = st.file_uploader("Upload an image of handwritten notes", type=["jpg", "jpeg", "png"]) | |
if uploaded_image: | |
img = Image.open(uploaded_image) | |
st.image(img, caption="Uploaded Image", use_column_width=True) | |
with st.spinner("Summarizing..."): | |
try: | |
response = model.generate_content( | |
[img, "Summarize the handwritten text in this image. Return the key points clearly."] | |
) | |
summary = response.text | |
st.success("Summary:") | |
st.markdown(summary) | |
except Exception as e: | |
st.error(f"β Failed to summarize: {str(e)}") | |