From e2399d1bad7329dc559e0056a2485e59e18dd51f Mon Sep 17 00:00:00 2001 From: Ankan Date: Tue, 22 Oct 2024 15:20:49 +0000 Subject: [PATCH] Added Text Sumarization NLP model --- .../Text Summarization Model/README.md | 29 +++++++++++++++++ .../textsummarizer.py | 31 +++++++++++++++++++ Web_Development/chatbot/README.md | 2 +- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Web_Development/Text Summarization Model/README.md create mode 100644 Web_Development/Text Summarization Model/textsummarizer.py diff --git a/Web_Development/Text Summarization Model/README.md b/Web_Development/Text Summarization Model/README.md new file mode 100644 index 0000000000..d586c5c4a2 --- /dev/null +++ b/Web_Development/Text Summarization Model/README.md @@ -0,0 +1,29 @@ +## **Text Summarization NLP MOdel** + +A text summarization NLP model where user and type their huge paragraphs and the model will summarize it + + +### 🎯 **Goal** + +Python Project - People do face issues to summarize huge texts or students do face issues to learn huge texts. this model helps users to summarize those texts and use it according to their need, for example a learner can easily learn faster and understand the summarized text instead of going through huge paragraphs + +Modules Used: + 1. Transformers + 2. Streamlit + 3. tf-keras + + +# MOdel Deployment with Streamlit +How to deploy: +- Deploy with Streamlit + +## Deployment: +``` +streamlit run textsummarizer.py +``` + +### ✒️ **Your Signature** + +`Ankan Mukhopadhyay` +[GitHub Profile](https://github.com/Peart-Guy) | [LinkedIn](https://www.linkedin.com/in/ankan-mukhopadhyaypeartguy/) + diff --git a/Web_Development/Text Summarization Model/textsummarizer.py b/Web_Development/Text Summarization Model/textsummarizer.py new file mode 100644 index 0000000000..70fcae820e --- /dev/null +++ b/Web_Development/Text Summarization Model/textsummarizer.py @@ -0,0 +1,31 @@ +import streamlit as st +from transformers import pipeline + +# Title of the web app +st.title("Text Summarization Tool") + +# Load the summarization model +@st.cache_resource(show_spinner=True) # Cache the model loading for faster performance +def load_summarizer(): + return pipeline("summarization", model="t5-small") + +summarizer = load_summarizer() + +# Instructions for users +st.write("Enter the text you'd like to summarize (minimum 50 words).") + +# Create a text area for the user to input text +user_input = st.text_area("Input Text", height=200) + +# A button to initiate the summarization process +if st.button("Summarize"): + if len(user_input.split()) < 50: + st.warning("Please enter at least 50 words for summarization.") + else: + # Show a spinner while the summarization is being processed + with st.spinner("Summarizing..."): + # Generate the summary + summary = summarizer(user_input, max_length=150, min_length=30, do_sample=False) + # Display the summarized text + st.subheader("Summary:") + st.write(summary[0]['summary_text']) diff --git a/Web_Development/chatbot/README.md b/Web_Development/chatbot/README.md index f9bea28508..2c48fa0449 100644 --- a/Web_Development/chatbot/README.md +++ b/Web_Development/chatbot/README.md @@ -55,5 +55,5 @@ $python app.py ### ✒️ **Your Signature** `Ankan Mukhopadhyay` -[GitHub Profile](https://github.com/Peart-Guy) | [LinkedIn](https://www.linkedin.com/in/ankan-mukhopadhyay-06baa4315/) +[GitHub Profile](https://github.com/Peart-Guy) | [LinkedIn](https://www.linkedin.com/in/ankan-mukhopadhyaypeartguy/)