Commit
·
90f5a24
1
Parent(s):
fb43824
create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
gen_kwargs = {"length_penalty": 0.8, "num_beams":8, "max_length": 128}
|
| 5 |
+
|
| 6 |
+
def main():
|
| 7 |
+
st.title("Text Summarizer App")
|
| 8 |
+
|
| 9 |
+
# Get user input
|
| 10 |
+
user_input = st.text_area("Enter text to summarize:")
|
| 11 |
+
|
| 12 |
+
# Button to trigger summarization
|
| 13 |
+
if st.button("Summarize"):
|
| 14 |
+
if user_input:
|
| 15 |
+
# Summarize the user input using the model
|
| 16 |
+
|
| 17 |
+
pipe = pipeline("summarization", model='ErnestBeckham/flan-t5-base-news-summarization', tokenizer='ErnestBeckham/flan-t5-base-news-summarization')
|
| 18 |
+
|
| 19 |
+
# Display the summarized output
|
| 20 |
+
st.subheader("Summary:")
|
| 21 |
+
st.write(pipe(user_input, **gen_kwargs)[0]["summary_text"])
|
| 22 |
+
else:
|
| 23 |
+
st.warning("Please enter text before summarizing.")
|
| 24 |
+
|
| 25 |
+
if __name__ == "__main__":
|
| 26 |
+
main()
|