Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,8 @@ from PIL import Image
|
|
10 |
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None, re.Pattern: lambda _: None}, allow_output_mutation=True, suppress_st_warning=True)
|
11 |
def get_model(model_name, model_path='pytorch_model.bin'):
|
12 |
tokenizer = transformers.GPT2Tokenizer.from_pretrained(model_name)
|
13 |
-
model = transformers.OPTForCausalLM.from_pretrained(
|
|
|
14 |
|
15 |
model.eval()
|
16 |
return model, tokenizer
|
|
|
10 |
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None, re.Pattern: lambda _: None}, allow_output_mutation=True, suppress_st_warning=True)
|
11 |
def get_model(model_name, model_path='pytorch_model.bin'):
|
12 |
tokenizer = transformers.GPT2Tokenizer.from_pretrained(model_name)
|
13 |
+
model = transformers.OPTForCausalLM.from_pretrained(model_name)
|
14 |
+
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
|
15 |
|
16 |
model.eval()
|
17 |
return model, tokenizer
|