File size: 1,028 Bytes
254bbd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
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)}")