Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -33,14 +33,14 @@ def t5_summarize(text):
|
|
33 |
return summary
|
34 |
|
35 |
#BART
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
#Encoder-Decoder
|
46 |
# def encoder_decoder(text):
|
@@ -55,7 +55,12 @@ def t5_summarize(text):
|
|
55 |
|
56 |
#st.write("Generated Summaries are: ")
|
57 |
# l=transform_summarize(text)
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
60 |
# print(bart_summarize(text))
|
61 |
# print(encoder_decoder(text))
|
|
|
33 |
return summary
|
34 |
|
35 |
#BART
|
36 |
+
def bart_summarize(text):
|
37 |
+
tokenizer = BartTokenizer.from_pretrained("facebook/bart-large-cnn")
|
38 |
+
model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn")
|
39 |
|
40 |
+
inputs = tokenizer([text], max_length=1024, return_tensors="pt", truncation=True)
|
41 |
+
summary_ids = model.generate(inputs["input_ids"], num_beams=4, max_length=150, early_stopping=True)
|
42 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
43 |
+
return summary
|
44 |
|
45 |
#Encoder-Decoder
|
46 |
# def encoder_decoder(text):
|
|
|
55 |
|
56 |
#st.write("Generated Summaries are: ")
|
57 |
# l=transform_summarize(text)
|
58 |
+
T5=t5_summarize(text)
|
59 |
+
B= bart_summarize(text)
|
60 |
+
st.title("Generated Summaries are:")
|
61 |
+
st.write("T5")
|
62 |
+
st.write(T5)
|
63 |
+
st.write("BART")
|
64 |
+
st.write(B)
|
65 |
# print(bart_summarize(text))
|
66 |
# print(encoder_decoder(text))
|