Manasa1 commited on
Commit
254bbd5
·
verified ·
1 Parent(s): ab937b1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as genai
3
+ import os
4
+ from PIL import Image
5
+
6
+ # Configure Gemini
7
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
8
+
9
+ # Load Gemini multimodal model
10
+ model = genai.GenerativeModel("gemini-pro-vision")
11
+
12
+ # Streamlit UI
13
+ st.set_page_config(page_title="Handwritten Notes Summarizer", layout="centered")
14
+ st.title("📝 Handwritten Notes Summarizer")
15
+
16
+ uploaded_image = st.file_uploader("Upload an image of handwritten notes", type=["jpg", "jpeg", "png"])
17
+
18
+ if uploaded_image:
19
+ img = Image.open(uploaded_image)
20
+ st.image(img, caption="Uploaded Image", use_column_width=True)
21
+
22
+ with st.spinner("Summarizing..."):
23
+ try:
24
+ response = model.generate_content(
25
+ [img, "Summarize the handwritten text in this image. Return the key points clearly."]
26
+ )
27
+ summary = response.text
28
+ st.success("Summary:")
29
+ st.markdown(summary)
30
+ except Exception as e:
31
+ st.error(f"❌ Failed to summarize: {str(e)}")