Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,33 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
gr.load("models/Arjun9/bart_samsum").launch()
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import BartForConditionalGeneration, BartTokenizer
|
3 |
+
|
4 |
+
st.set_page_config(page_title="BART Text Summarization", layout="centered")
|
5 |
+
|
6 |
+
@st.cache_resource
|
7 |
+
def load_model():
|
8 |
+
model = BartForConditionalGeneration.from_pretrained("Arjun9/bart_samsum")
|
9 |
+
tokenizer = BartTokenizer.from_pretrained("Arjun9/bart_samsum")
|
10 |
+
return model, tokenizer
|
11 |
+
|
12 |
+
model, tokenizer = load_model()
|
13 |
+
|
14 |
+
def main():
|
15 |
+
st.title("Meeting summarization")
|
16 |
+
|
17 |
+
# Get user input
|
18 |
+
input_text = st.text_area("Enter text to summarize", height=200)
|
19 |
+
|
20 |
+
if st.button("Summarize"):
|
21 |
+
# Tokenize the input text
|
22 |
+
inputs = tokenizer(input_text, return_tensors="pt", truncation=True)
|
23 |
+
|
24 |
+
# Generate summary
|
25 |
+
summary_ids = model.generate(inputs["input_ids"], num_beams=4, max_length=100, early_stopping=True)
|
26 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
27 |
+
|
28 |
+
# Display the summary
|
29 |
+
st.write(f"Summary: {summary}")
|
30 |
+
|
31 |
+
if __name__ == "__main__":
|
32 |
+
main()
|
33 |
|
|