ismaelR commited on
Commit
e916ec8
·
1 Parent(s): c01c953

with input

Browse files
Files changed (1) hide show
  1. app.py +19 -23
app.py CHANGED
@@ -1,29 +1,25 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- pipeline = pipeline(task="summarization", model="lidiya/bart-large-xsum-samsum")
 
5
 
6
- st.title("Résumé de conversation avec BART")
7
- txt = """Hannah: Hey, do you have Betty's number?
8
- Amanda: Lemme check
9
- Amanda: Sorry, can't find it.
10
- Amanda: Ask Larry
11
- Amanda: He called her last time we were at the park together
12
- Hannah: I don't know him well
13
- Amanda: Don't be shy, he's very nice
14
- Hannah: If you say so..
15
- Hannah: I'd rather you texted him
16
- Amanda: Just text him 🙂
17
- Hannah: Urgh.. Alright
18
- Hannah: Bye
19
- Amanda: Bye bye
20
- """
21
 
22
- col1, col2 = st.columns(2)
23
- summary = pipeline(txt)
 
 
24
 
25
- col1.header("Texte original")
26
- col1.subheader(txt)
27
-
28
- col2.header("Texte résumé")
29
- col2.subheader(summary)
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Set up the summarization pipeline
5
+ summarizer = pipeline(task="summarization", model="lidiya/bart-large-xsum-samsum")
6
 
7
+ # Title for the Streamlit app
8
+ st.title("Huggingface Summarizer App")
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ # Create a sidebar for input
11
+ with st.sidebar:
12
+ st.header("Input")
13
+ input_text = st.text_area("Enter your text to be summarized:")
14
 
15
+ # Create a button to start the summarization
16
+ if st.button("Summarize"):
17
+ # If the input box isn't empty, process the input and generate a summary
18
+ if input_text:
19
+ summary = summarizer(input_text, max_length=256, min_length=0, do_sample=False)
20
+ st.subheader("Summary")
21
+ st.write(summary[0]["summary_text"])
22
+ else:
23
+ st.warning("Please enter some text to summarize.")
24
+ else:
25
+ st.subheader("Summary will appear here...")