Spaces:
Runtime error
Runtime error
Eunchan Lee
commited on
Commit
·
72c6f28
1
Parent(s):
bdd6014
abs sum
Browse files
app.py
CHANGED
@@ -13,13 +13,33 @@ import torch
|
|
13 |
|
14 |
|
15 |
|
|
|
|
|
|
|
16 |
x = st.slider('Select a value')
|
|
|
|
|
17 |
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
st.write(x, 'squared is', x * x)
|
22 |
|
|
|
23 |
|
|
|
24 |
|
25 |
-
st.write('
|
|
|
13 |
|
14 |
|
15 |
|
16 |
+
|
17 |
+
'''
|
18 |
+
basic line example
|
19 |
x = st.slider('Select a value')
|
20 |
+
st.write(x, 'squared is', x * x)
|
21 |
+
'''
|
22 |
|
23 |
|
24 |
+
def pegasus_abs_summarize(src_text):
|
25 |
+
|
26 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
27 |
+
model_name_xsum = 'google/pegasus-xsum'
|
28 |
+
|
29 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_xsum)
|
30 |
+
model = PegasusForConditionalGeneration.from_pretrained(model_name_xsum).to(device)
|
31 |
+
|
32 |
+
batch = tokenizer(src_text, truncation=True, padding='longest', return_tensors="pt").to(device)
|
33 |
+
|
34 |
+
translated = model.generate(**batch)
|
35 |
+
|
36 |
+
target_text = tokenizer.batch_decode(translated, skip_special_tokens =True)
|
37 |
+
|
38 |
+
return target_text
|
39 |
|
|
|
40 |
|
41 |
+
st.text_input("Input:", key="input")
|
42 |
|
43 |
+
abs_output = pegasus_abs_summarize(st.session_state.input)
|
44 |
|
45 |
+
st.write('Abstractive output', abs_output)
|