Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import streamlit as st
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Load the summarization pipeline with the specified model
|
6 |
+
pipe = pipeline("summarization", model="Yihui/t5-small-text-summary-generation")
|
7 |
+
|
8 |
+
# Set the title of the app
|
9 |
+
st.title("Summary Generator")
|
10 |
+
st.markdown("<p style='color:blue; font-size:20px;'>Developed by Usman</p>", unsafe_allow_html=True)
|
11 |
+
st.markdown("<p style='color:red; font-size:15px;'>Based on Hugging Face Model</p>", unsafe_allow_html=True)
|
12 |
+
|
13 |
+
# Create a text area for user input
|
14 |
+
input_text = st.text_area("Enter the text you want to get summarize:", height=200)
|
15 |
+
|
16 |
+
# Create a button to trigger the summarization
|
17 |
+
if st.button("Summarize"):
|
18 |
+
if input_text:
|
19 |
+
# Generate the summary
|
20 |
+
summary = pipe(input_text, max_length=150, min_length=30, do_sample=False)
|
21 |
+
|
22 |
+
# Display the summarized text
|
23 |
+
st.subheader("Summary:")
|
24 |
+
st.write(summary[0]['summary_text'])
|
25 |
+
else:
|
26 |
+
st.error("Please enter some text to summarize.")
|