| """ | |
| Module to load the project models | |
| """ | |
| import os | |
| import tensorflow_text | |
| import tensorflow as tf | |
| import tensorflow_hub as hub | |
| CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| def load_sentiments_model(): | |
| """ | |
| Load pretrained model | |
| """ | |
| model_path = os.path.join(CURRENT_DIR, "sentiments_bert_model.h5") | |
| model = tf.keras.models.load_model( | |
| model_path, custom_objects={"KerasLayer": hub.KerasLayer}, compile=False | |
| ) | |
| return model | |