Spaces:
Sleeping
Sleeping
Download text_summary.py from AIROBOHUB/Smart-AI-Tools: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/AIROBOHUB/Smart-AI-Tools/resolve/main/text_summary.py
- Command line
-
hf download hf://spaces/AIROBOHUB/Smart-AI-Tools/text_summary.py
-
curl -L -o text_summary.py https://huggingface.co/spaces/AIROBOHUB/Smart-AI-Tools/resolve/main/text_summary.py
1.05 kB
| import streamlit as st | |
| from transformers import pipeline | |
| # Load the summarization pipeline | |
| text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") | |
| def summarize_text(input_text): | |
| output = text_summary(input_text) | |
| return output[0]['summary_text'] | |
| def run(): | |
| st.title("π Text Summary Tool") | |
| st.write("This tool helps you summarize long pieces of text efficiently using AI-powered NLP models.") | |
| st.write("Enter a large text below to generate a summary.") | |
| text = st.text_area("This tool helps you summarize long pieces of text efficiently using AI-powered NLP models.") | |
| # text = st.text_area("Enter your text here:", "") | |
| if st.button("π Summarize", help="Click to generate summary"): | |
| if text: | |
| with st.spinner("Generating summary..."): | |
| summary_result = summarize_text(text) | |
| st.markdown("### π Summarized Text:") | |
| st.success(summary_result) | |
| else: | |
| st.warning("β οΈ Please enter some text to summarize.") |