Download utils/tokenizer_utils.py from danhtran2mind/En-Vi-Translation-Transformer-TensorFlow: direct link, hf CLI and curl.
- Browser
- Download file 528 Bytes
-
https://huggingface.co/spaces/danhtran2mind/En-Vi-Translation-Transformer-TensorFlow/resolve/main/utils/tokenizer_utils.py
- Command line
-
hf download hf://spaces/danhtran2mind/En-Vi-Translation-Transformer-TensorFlow/utils/tokenizer_utils.py
-
curl -L -o tokenizer_utils.py https://huggingface.co/spaces/danhtran2mind/En-Vi-Translation-Transformer-TensorFlow/resolve/main/utils/tokenizer_utils.py
528 Bytes
| import pickle | |
| import tensorflow as tf | |
| def load_tokenizers(en_path='tokenizers/en_tokenizer.pkl', | |
| vi_path='tokenizers/vi_tokenizer.pkl'): | |
| with open(en_path, 'rb') as f: | |
| en_tokenizer = pickle.load(f) | |
| with open(vi_path, 'rb') as f: | |
| vi_tokenizer = pickle.load(f) | |
| en_tokenizer = tf.keras.preprocessing.text.tokenizer_from_json(en_tokenizer) | |
| vi_tokenizer = tf.keras.preprocessing.text.tokenizer_from_json(vi_tokenizer) | |
| return en_tokenizer, vi_tokenizer | |