Views
No views yet
1from datasets import load_dataset
2from huggingface_hub import hf_hub_download
3from keras_preprocessing.sequence import pad_sequences
4
5# Download the surrogate model
6hf_hub_download(repo_id="AiresPucrs/surrogate-model",
7 filename="surrogate_model.h5",
8 local_dir="./",
9 repo_type="model"
10 )
11
12# Download the surrogate tokenizer file
13hf_hub_download(repo_id="AiresPucrs/surrogate-model",
14 filename="tokenizer_surrogate_model.json",
15 local_dir="./",
16 repo_type="model"
17 )
18surrogate_model = tf.keras.models.load_model('./surrogate_model.h5')
19
20with open('./tokenizer_surrogate_model.json') as fp:
21 data = json.load(fp)
22 tokenizer_surrogate = tf.keras.preprocessing.text.tokenizer_from_json(data)
23 word_index_surrogate = tokenizer_surrogate.word_index
24 fp.close()