sathvikk commited on
Commit
52621a3
Β·
verified Β·
1 Parent(s): c0f9dde

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +4 -11
src/streamlit_app.py CHANGED
@@ -1,16 +1,15 @@
1
  import streamlit as st
2
- import fitz
3
  from transformers import pipeline
4
 
5
  # Set page config
6
  st.set_page_config(page_title="PrepPal", page_icon="πŸ“˜", layout="wide")
7
 
8
- # Load summarizer model (using Hugging Face pipeline)
9
  @st.cache_resource
10
  def load_summarizer():
11
  return pipeline("summarization", model="t5-small")
12
 
13
-
14
  # PDF text extraction
15
  def extract_text_from_pdf(uploaded_file):
16
  text = ""
@@ -27,17 +26,14 @@ def summarize_text(text, summarizer, max_chunk_length=2000):
27
  chunks = [text[i:i + max_chunk_length] for i in range(0, len(text), max_chunk_length)]
28
  summary = ""
29
  for chunk in chunks:
30
- result = summarizer(chunk, max_length=130, min_length=30, do_sample=False) # Corrected 'false' to 'False'
31
  summary += result[0]['summary_text'] + "\n"
32
  return summary.strip()
33
 
34
- # Load summarizer model
35
  summarizer = load_summarizer()
36
 
37
- # Tabs
38
  tab1, tab2, tab3 = st.tabs(["πŸ“„ Summarize Notes", "❓ Ask a Doubt", "πŸ’¬ Feedback"])
39
 
40
- # Tab 1: Summarizer
41
  with tab1:
42
  st.header("πŸ“„ Upload Notes & Get Summary")
43
  st.write("Upload your class notes in PDF format to receive a summarized version.")
@@ -56,17 +52,14 @@ with tab1:
56
  summary = summarize_text(pdf_text, summarizer)
57
  st.subheader("βœ… Summary")
58
  st.text_area("Summary Output", summary, height=300)
59
-
60
  st.download_button("⬇️ Download Summary", summary, file_name="summary.txt")
61
  else:
62
  st.warning("⚠️ No text found in the uploaded PDF.")
63
 
64
- # Tab 2: Ask a Doubt (coming soon)
65
  with tab2:
66
  st.header("❓ Ask a Doubt")
67
  st.info("πŸ”§ This feature is under development. You’ll soon be able to chat with your notes using AI!")
68
 
69
- # Tab 3: Feedback (coming soon)
70
  with tab3:
71
  st.header("πŸ’¬ User Feedback")
72
- st.info("πŸ“¬ A feedback form will be added here to collect your thoughts and improve PrepPal.")
 
1
  import streamlit as st
2
+ import fitz # PyMuPDF for PDF extraction
3
  from transformers import pipeline
4
 
5
  # Set page config
6
  st.set_page_config(page_title="PrepPal", page_icon="πŸ“˜", layout="wide")
7
 
8
+ # Load summarizer model
9
  @st.cache_resource
10
  def load_summarizer():
11
  return pipeline("summarization", model="t5-small")
12
 
 
13
  # PDF text extraction
14
  def extract_text_from_pdf(uploaded_file):
15
  text = ""
 
26
  chunks = [text[i:i + max_chunk_length] for i in range(0, len(text), max_chunk_length)]
27
  summary = ""
28
  for chunk in chunks:
29
+ result = summarizer(chunk, max_length=130, min_length=30, do_sample=False)
30
  summary += result[0]['summary_text'] + "\n"
31
  return summary.strip()
32
 
 
33
  summarizer = load_summarizer()
34
 
 
35
  tab1, tab2, tab3 = st.tabs(["πŸ“„ Summarize Notes", "❓ Ask a Doubt", "πŸ’¬ Feedback"])
36
 
 
37
  with tab1:
38
  st.header("πŸ“„ Upload Notes & Get Summary")
39
  st.write("Upload your class notes in PDF format to receive a summarized version.")
 
52
  summary = summarize_text(pdf_text, summarizer)
53
  st.subheader("βœ… Summary")
54
  st.text_area("Summary Output", summary, height=300)
 
55
  st.download_button("⬇️ Download Summary", summary, file_name="summary.txt")
56
  else:
57
  st.warning("⚠️ No text found in the uploaded PDF.")
58
 
 
59
  with tab2:
60
  st.header("❓ Ask a Doubt")
61
  st.info("πŸ”§ This feature is under development. You’ll soon be able to chat with your notes using AI!")
62
 
 
63
  with tab3:
64
  st.header("πŸ’¬ User Feedback")
65
+ st.info("πŸ“¬ A feedback form will be added here to collect your thoughts and improve PrepPal.")