File size: 475 Bytes
93109de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
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