Update summary.py
Browse files- summary.py +2 -2
summary.py
CHANGED
@@ -2,13 +2,13 @@ import torch
|
|
2 |
import streamlit as st
|
3 |
from transformers import PegasusForConditionalGeneration, AutoTokenizer
|
4 |
|
5 |
-
@st.cache(allow_output_mutation=True)
|
6 |
-
|
7 |
model_name = 'google/pegasus-cnn_dailymail'
|
8 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
model = PegasusForConditionalGeneration.from_pretrained(model_name).to(device)
|
11 |
|
|
|
|
|
12 |
def summarize(passage):
|
13 |
txt = " ".join(passage)
|
14 |
batch = tokenizer(txt, truncation=True, padding='longest', return_tensors="pt").to(device)
|
|
|
2 |
import streamlit as st
|
3 |
from transformers import PegasusForConditionalGeneration, AutoTokenizer
|
4 |
|
|
|
|
|
5 |
model_name = 'google/pegasus-cnn_dailymail'
|
6 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
model = PegasusForConditionalGeneration.from_pretrained(model_name).to(device)
|
9 |
|
10 |
+
@st.cache(allow_output_mutation=True)
|
11 |
+
|
12 |
def summarize(passage):
|
13 |
txt = " ".join(passage)
|
14 |
batch = tokenizer(txt, truncation=True, padding='longest', return_tensors="pt").to(device)
|