handwritten_doc / app.py
Manasa1's picture
Create app.py
254bbd5 verified
raw
history blame
1.03 kB
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)}")