Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,18 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
st.
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
min_len = st.slider("Min Summary Length", 10, 50, 25)
|
| 20 |
-
|
| 21 |
-
if st.button("Generate TL;DR"):
|
| 22 |
-
if text_to_summarize.strip():
|
| 23 |
-
with st.spinner("Analyzing and condensing..."):
|
| 24 |
-
output = summarizer(
|
| 25 |
-
text_to_summarize,
|
| 26 |
-
max_length=max_len,
|
| 27 |
-
min_length=min_len,
|
| 28 |
-
do_sample=False
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
st.success("Summary Generated")
|
| 32 |
-
st.write(f"### Result:")
|
| 33 |
-
st.write(output[0]['summary_text'])
|
| 34 |
-
else:
|
| 35 |
-
st.warning("Please paste some text first!")
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
MODEL_ID = "VoltIC/Automated-Text-Summarizer"
|
| 5 |
+
|
| 6 |
+
@st.cache_resource
|
| 7 |
+
def load_summarizer():
|
| 8 |
+
return pipeline("summarization", model=MODEL_ID)
|
| 9 |
+
|
| 10 |
+
summarizer = load_summarizer()
|
| 11 |
+
|
| 12 |
+
st.title("AI Text Summarizer")
|
| 13 |
+
input_text = st.text_area("Paste text here...")
|
| 14 |
+
|
| 15 |
+
if st.button("Summarize"):
|
| 16 |
+
if input_text:
|
| 17 |
+
summary = summarizer(input_text, max_length=100, min_length=30)
|
| 18 |
+
st.write(summary[0]['summary_text'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|