Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,9 +13,14 @@ st.title('KoGPT2 Demo')
|
|
| 13 |
|
| 14 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
g = """
|
| 21 |
informal english: the vice president is not automatically entitled to the nomination, if they are unpopular.
|
|
@@ -34,7 +39,7 @@ Translated into the Style of Abraham Lincoln: without fail, one railroad after a
|
|
| 34 |
informal english:"""
|
| 35 |
|
| 36 |
with st.form(key='my_form'):
|
| 37 |
-
prompt = st.text_area(label='Enter sentence',
|
| 38 |
submit_button = st.form_submit_button(label='Submit')
|
| 39 |
|
| 40 |
if submit_button:
|
|
|
|
| 13 |
|
| 14 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 15 |
|
| 16 |
+
|
| 17 |
+
@st.cache(allow_output_mutation=True)
|
| 18 |
+
def load_model():
|
| 19 |
+
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 20 |
+
model = AutoModelWithLMHead.from_pretrained("BigSalmon/MrLincoln10")
|
| 21 |
+
return tokenizer, model
|
| 22 |
+
|
| 23 |
+
load_model()
|
| 24 |
|
| 25 |
g = """
|
| 26 |
informal english: the vice president is not automatically entitled to the nomination, if they are unpopular.
|
|
|
|
| 39 |
informal english:"""
|
| 40 |
|
| 41 |
with st.form(key='my_form'):
|
| 42 |
+
prompt = st.text_area(label='Enter sentence', value=g)
|
| 43 |
submit_button = st.form_submit_button(label='Submit')
|
| 44 |
|
| 45 |
if submit_button:
|