Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load summarization model from Hugging Face
|
5 |
+
summarizer = pipeline("summarization", model="google/pegasus-xsum")
|
6 |
+
|
7 |
+
# Streamlit UI
|
8 |
+
def main():
|
9 |
+
st.title("Text Summarization App")
|
10 |
+
|
11 |
+
# User input
|
12 |
+
user_input = st.text_area("Enter your text for summarization:")
|
13 |
+
|
14 |
+
if st.button("Generate Summary"):
|
15 |
+
if user_input:
|
16 |
+
# Perform summarization
|
17 |
+
summary = summarizer(user_input, max_length=150, min_length=50, length_penalty=2.0, num_beams=4)[0]['summary_text']
|
18 |
+
|
19 |
+
# Display result
|
20 |
+
st.write("Summary:")
|
21 |
+
st.write(summary)
|
22 |
+
else:
|
23 |
+
st.warning("Please enter some text for summarization.")
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
main()
|