Spaces:
Runtime error
Runtime error
Galuh Sahid
commited on
Commit
•
d222a2c
1
Parent(s):
23a40c8
remove cache params
Browse files
app.py
CHANGED
@@ -19,13 +19,13 @@ MODELS = {
|
|
19 |
|
20 |
headers = {}
|
21 |
|
22 |
-
@st.cache(
|
23 |
def load_gpt(model_type):
|
24 |
model = GPT2LMHeadModel.from_pretrained(MODELS[model_type])
|
25 |
|
26 |
return model
|
27 |
|
28 |
-
@st.cache(
|
29 |
def load_gpt_tokenizer(model_type):
|
30 |
tokenizer = GPT2Tokenizer.from_pretrained(MODELS[model_type])
|
31 |
|
@@ -108,6 +108,7 @@ session_state = SessionState.get(prompt=None, prompt_box=None, text=None)
|
|
108 |
ALL_PROMPTS = list(PROMPT_LIST[prompt_group_name].keys())+["Custom"]
|
109 |
prompt = st.selectbox('Prompt', ALL_PROMPTS, index=len(ALL_PROMPTS)-1)
|
110 |
|
|
|
111 |
if session_state.prompt is None:
|
112 |
session_state.prompt = prompt
|
113 |
elif session_state.prompt is not None and (prompt != session_state.prompt):
|
@@ -117,6 +118,7 @@ elif session_state.prompt is not None and (prompt != session_state.prompt):
|
|
117 |
else:
|
118 |
session_state.prompt = prompt
|
119 |
|
|
|
120 |
if session_state.prompt == "Custom":
|
121 |
session_state.prompt_box = "Enter your text here"
|
122 |
else:
|
|
|
19 |
|
20 |
headers = {}
|
21 |
|
22 |
+
@st.cache()
|
23 |
def load_gpt(model_type):
|
24 |
model = GPT2LMHeadModel.from_pretrained(MODELS[model_type])
|
25 |
|
26 |
return model
|
27 |
|
28 |
+
@st.cache(hash_funcs={transformers.models.gpt2.tokenization_gpt2.GPT2Tokenizer: lambda _: None})
|
29 |
def load_gpt_tokenizer(model_type):
|
30 |
tokenizer = GPT2Tokenizer.from_pretrained(MODELS[model_type])
|
31 |
|
|
|
108 |
ALL_PROMPTS = list(PROMPT_LIST[prompt_group_name].keys())+["Custom"]
|
109 |
prompt = st.selectbox('Prompt', ALL_PROMPTS, index=len(ALL_PROMPTS)-1)
|
110 |
|
111 |
+
# Update prompt
|
112 |
if session_state.prompt is None:
|
113 |
session_state.prompt = prompt
|
114 |
elif session_state.prompt is not None and (prompt != session_state.prompt):
|
|
|
118 |
else:
|
119 |
session_state.prompt = prompt
|
120 |
|
121 |
+
# Update prompt box
|
122 |
if session_state.prompt == "Custom":
|
123 |
session_state.prompt_box = "Enter your text here"
|
124 |
else:
|