sharath6900 commited on
Commit
bf7b3cb
·
verified ·
1 Parent(s): ff28250

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the summarization pipeline
5
+ summarizer = pipeline("summarization")
6
+
7
+ def summarize_text(text):
8
+ """Summarize the input text using Hugging Face's pipeline."""
9
+ summary = summarizer(text, max_length=150, min_length=50, do_sample=False)
10
+ return summary[0]['summary_text']
11
+
12
+ # Streamlit UI
13
+ st.title("Text Summarization with Hugging Face")
14
+
15
+ st.write("Enter the text you want to summarize:")
16
+
17
+ # Text input from the user
18
+ user_input = st.text_area("Input Text", height=200)
19
+
20
+ if st.button("Summarize"):
21
+ if user_input:
22
+ # Generate summary
23
+ summary = summarize_text(user_input)
24
+ st.subheader("Summary:")
25
+ st.write(summary)
26
+ else:
27
+ st.error("Please enter some text to summarize.")
28
+