Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,9 +4,8 @@ import pandas as pd
|
|
4 |
import os
|
5 |
import torch
|
6 |
import torch.nn as nn
|
7 |
-
from transformers import
|
8 |
from transformers.activations import get_activation
|
9 |
-
from transformers import AutoTokenizer
|
10 |
|
11 |
|
12 |
st.title('Informal to Formal')
|
@@ -35,10 +34,13 @@ Translated into the Style of Abraham Lincoln: corn fields ( permeate illinois /
|
|
35 |
|
36 |
informal english:''')
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
41 |
-
model = AutoModelWithLMHead.from_pretrained("BigSalmon/MrLincoln12")
|
|
|
|
|
|
|
42 |
|
43 |
with st.form(key='my_form'):
|
44 |
prompt = st.text_area(label='Enter sentence')
|
|
|
4 |
import os
|
5 |
import torch
|
6 |
import torch.nn as nn
|
7 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
8 |
from transformers.activations import get_activation
|
|
|
9 |
|
10 |
|
11 |
st.title('Informal to Formal')
|
|
|
34 |
|
35 |
informal english:''')
|
36 |
|
37 |
+
@st.cache(allow_output_mutation=True)
|
38 |
+
def get_model():
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
40 |
+
model = AutoModelWithLMHead.from_pretrained("BigSalmon/MrLincoln12")
|
41 |
+
return model, tokenizer
|
42 |
+
|
43 |
+
model, tokenizer = get_model()
|
44 |
|
45 |
with st.form(key='my_form'):
|
46 |
prompt = st.text_area(label='Enter sentence')
|