The entire error message goes on like this:
(tf) plastic@lenovo-ideapad-slim5:~/dev/temp$ python app.py
Traceback (most recent call last):
File "/home/plastic/dev/temp/app.py", line 13, in
from scoring import get_score
File "/home/plastic/dev/temp/scoring.py", line 13, in
model = tf.saved_model.load('./model/')
File "/home/plastic/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/saved_model/load.py", line 864, in load
result = load_internal(export_dir, tags, options)["root"]
File "/home/plastic/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/saved_model/load.py", line 902, in load_internal
loader = loader_cls(object_graph_proto, saved_model_proto, export_dir,
File "/home/plastic/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/saved_model/load.py", line 162, in __init__
self._load_all()
File "/home/plastic/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/saved_model/load.py", line 259, in _load_all
self._load_nodes()
File "/home/plastic/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/saved_model/load.py", line 448, in _load_nodes
slot_variable = optimizer_object.add_slot(
AttributeError: '_UserObject' object has no attribute 'add_slot'
cause due to the line model = tf.saved_model.load('./model/')
Due to recent upgrades in tensorflow and keras, changing the imports and this line of code to the following fixes the error:
import imageio
import keras
import os
import cv2
import numpy as np
import random
#from tensorflow_docs.vis import embed
MAX_SEQ_LENGTH = 100
NUM_FEATURES = 2048
IMG_SIZE = 224
model = keras.models.load_model('./model/')
Lines to be changed are importing keras directly, removing tensorflow imports, removing keras api imports and changing tf.keras.saved_model.load("path")
to keras.models.load_model("path")