Skip to content

Commit

Permalink
lamma
Browse files Browse the repository at this point in the history
  • Loading branch information
Olawale Abimbola committed Jan 19, 2024
1 parent 7bb9812 commit 6a3b5ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
26 changes: 12 additions & 14 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import streamlit as st
import os
import tempfile
from src.pytesseract_ocr import PDFToTextConverter
from src.pytesseract_ocr import PDFToTextConverter
from src.summarizer import TextSummarizer

# Initialize the summarizer
# summarizer = TextSummarizer()
summarizer = TextSummarizer()

# Custom CSS for styling
st.markdown("""
Expand Down Expand Up @@ -52,12 +52,11 @@ def process_pdf(file_path):

# Main container
with st.container():
st.write("## Summary Output")
st.write("## INTELLECTSUMMARIZER")
st.markdown("""
This tool allows you to extract and summarize text from PDF documents or directly from your input.
Choose your preferred method and get concise summaries quickly and efficiently.
""")
output_container = st.empty()

# Handle PDF upload
if option == "Upload PDF":
Expand All @@ -74,11 +73,11 @@ def process_pdf(file_path):
os.remove(tmp.name)

if extracted_text:
# summarized_text = summarizer.summarize(extracted_text)
output_container.markdown("### Extracted Text:")
output_container.write(extracted_text)
output_container.markdown("### Summarized Text:")
# output_container.write(summarized_text)
summarized_text = summarizer.summarize(extracted_text)
st.markdown("### Original Text:")
st.text_area("Extracted Text:", value=extracted_text, height=150, disabled=True)
st.markdown("### Summarized Text:")
st.text_area("Summary:", value=summarized_text, height=100, disabled=True)
else:
st.error("No text extracted from PDF.")
else:
Expand All @@ -91,10 +90,9 @@ def process_pdf(file_path):

if st.button('Summarize Text'):
if user_input_text:
# summarized_text = summarizer.summarize(user_input_text)
output_container.markdown("### Original Text:")
output_container.write(user_input_text)
output_container.markdown("### Summarized Text:")
# output_container.write(summarized_text)
summarized_text = summarizer.summarize(user_input_text)
# print(summarized_text)
st.markdown("### Summarized Text:")
st.text_area("Summary:", value=summarized_text, height=100, disabled=True)
else:
st.error("Please enter some text to process.")
2 changes: 1 addition & 1 deletion src/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, model_name="facebook/bart-large-cnn"):
self.model_name = model_name
self.summarizer = pipeline("summarization", model=self.model_name)

def summarize(self, text, max_length=50, min_length=5):
def summarize(self, text, max_length=10000, min_length=5):
"""
Summarize the given text using the loaded model.
Expand Down

0 comments on commit 6a3b5ae

Please sign in to comment.