Spaces:
Runtime error
Runtime error
Download model.py from flax-community/SinhalaLanguageDemos: direct link, hf CLI and curl.
- Browser
- Download file 456 Bytes
-
https://huggingface.co/spaces/flax-community/SinhalaLanguageDemos/resolve/main/model.py
- Command line
-
hf download hf://spaces/flax-community/SinhalaLanguageDemos/model.py
-
curl -L -o model.py https://huggingface.co/spaces/flax-community/SinhalaLanguageDemos/resolve/main/model.py
456 Bytes
| import streamlit as st | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| def load_model(model_name): | |
| with st.spinner('Waiting for the model to load.....'): | |
| # snapshot_download('flax-community/Sinhala-gpt2') | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForCausalLM.from_pretrained(model_name, pad_token_id=tokenizer.eos_token_id) | |
| st.success('Model loaded!!') | |
| return model, tokenizer |