EmreYY20 commited on
Commit
57f2e36
1 Parent(s): c0ae847
Files changed (1) hide show
  1. app.py +56 -2
app.py CHANGED
@@ -1,4 +1,58 @@
1
  import streamlit as st
 
 
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ import PyPDF2
4
+ import base64
5
+ from summarizer import bert_summarizer, simple_summarizer
6
 
7
+ summarizer = bert_summarizer
8
+
9
+ # Set page to wide mode
10
+ st.set_page_config(layout="wide")
11
+
12
+ # Function to handle file upload and return its content
13
+ def load_pdf(file):
14
+ pdf_reader = PyPDF2.PdfReader(file)
15
+ pdf_text = ""
16
+ for page_num in range(len(pdf_reader.pages)):
17
+ pdf_text += pdf_reader.pages[page_num].extract_text()
18
+ return pdf_text
19
+
20
+ # Main app
21
+ def main():
22
+
23
+ st.title("Streamlit App")
24
+
25
+ # Layout: 3 columns
26
+ col1, col2, col3 = st.columns([1, 3, 2], gap="large")
27
+
28
+ # Left column: Dropdown menu
29
+ with col1:
30
+ dropdown_options = ['Abstractive', 'Extractive']
31
+ dropdown_selection = st.selectbox("Choose type of summerizer:", dropdown_options)
32
+
33
+ # Middle column: Text input and File uploader
34
+ with col2:
35
+ user_input = st.text_input("Enter your text here:")
36
+ uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
37
+ if st.button("Summarize"):
38
+ # Handling file upload
39
+ if uploaded_file is not None:
40
+ file_content = load_pdf(uploaded_file)
41
+ st.write("PDF uploaded successfully.")
42
+ # summary = summarizer(file_content)
43
+ summary = file_content
44
+ elif user_input is not None:
45
+ # summary = summarizer(user_input)
46
+ summary = user_input
47
+ else:
48
+ st.wirte("Upload a PDF or put in your text!")
49
+ st.session_state.summary = summary
50
+
51
+ # Right column: Displaying text after pressing 'Summarize'
52
+ with col3:
53
+ st.write("Output:")
54
+ if 'summary' in st.session_state:
55
+ st.write(st.session_state.summary)
56
+
57
+ if __name__ == "__main__":
58
+ main()