richardorama
commited on
Commit
•
66d3e3b
1
Parent(s):
c8d7667
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
|
24 |
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
|
25 |
|
26 |
# Streamlit UI for input
|
27 |
-
st.
|
28 |
|
29 |
# Input text area for the article
|
30 |
article = st.text_area("Enter the text you want to summarize", height=300)
|
@@ -47,7 +47,32 @@ if st.button("Summarize"):
|
|
47 |
else:
|
48 |
st.warning("Please enter some text to summarize!")
|
49 |
|
|
|
|
|
|
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
################ STATEMENT SUMMARIZATION #################
|
53 |
|
|
|
24 |
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
|
25 |
|
26 |
# Streamlit UI for input
|
27 |
+
st.markdown("<h3 style='text-align: center; font-size: 20px;'>Text Summarization with BART</h3>", unsafe_allow_html=True)
|
28 |
|
29 |
# Input text area for the article
|
30 |
article = st.text_area("Enter the text you want to summarize", height=300)
|
|
|
47 |
else:
|
48 |
st.warning("Please enter some text to summarize!")
|
49 |
|
50 |
+
DEFAULT_STATEMENT = ""
|
51 |
+
# Create a text area for user input
|
52 |
+
STATEMENT = st.sidebar.text_area('Enter Statement (String)', DEFAULT_STATEMENT, height=150)
|
53 |
|
54 |
+
# Enable the button only if there is text in the SENTIMENT variable
|
55 |
+
if STATEMENT:
|
56 |
+
if st.sidebar.button('Summarize Statement'):
|
57 |
+
# Call your Summarize function here
|
58 |
+
# summarize_statement(STATEMENT) # Directly pass the STATEMENT
|
59 |
+
|
60 |
+
# Tokenize input article
|
61 |
+
inputs = tokenizer(STATEMENT, return_tensors="pt", truncation=True, padding="longest", max_length=1024)
|
62 |
+
|
63 |
+
# Generate summary
|
64 |
+
summary_ids = model.generate(inputs["input_ids"], max_length=150, min_length=30, length_penalty=2.0, num_beams=4, early_stopping=True)
|
65 |
+
|
66 |
+
# Decode summary
|
67 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
68 |
+
|
69 |
+
# Display the summary
|
70 |
+
st.write("**Summary:**")
|
71 |
+
st.write(summary)
|
72 |
+
else:
|
73 |
+
st.sidebar.button('Summarize Statement', disabled=True)
|
74 |
+
st.warning('👈 Please enter Statement!')
|
75 |
+
|
76 |
|
77 |
################ STATEMENT SUMMARIZATION #################
|
78 |
|