From fd5da5bc5c96bcdceeb482a60db5552d50576171 Mon Sep 17 00:00:00 2001 From: jcollopy-tulane Date: Mon, 29 Apr 2024 02:25:00 -0500 Subject: [PATCH] Adding --- nlp/cli.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nlp/cli.py b/nlp/cli.py index eb6e831..0d2f1ce 100644 --- a/nlp/cli.py +++ b/nlp/cli.py @@ -162,12 +162,13 @@ def train_cnn(): dir_path = os.path.dirname(os.path.realpath(__file__)) model_path = os.path.join(dir_path, 'cnn_model.h5') tokenizer_path = os.path.join(dir_path, 'tokenizer.pickle') - cnn = load_model(model_path) # Model derived in Experiments-CNN.ipynb file - - - with open(tokenizer_path, 'rb') as handle: - tokenizer = pickle.load(handle) - + try: + cnn = load_model(model_path) + with open(tokenizer_path, 'rb') as handle: + tokenizer = pickle.load(handle) + except Exception as e: + print(f"Error loading model or tokenizer: {e}") + return X_train = train_df["Comment_Adj"].apply(cnn_process) # See functions_utils.py file X_val = val_df["Comment_Adj"].apply(cnn_process) # See functions_utils.py file