santit96's picture
Initialize project and create a first sentiment classifier prototype with streamlit and a pretrained bert model
93109de
raw
history blame
475 Bytes
"""
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