ValueError: Exception encountered when calling layer "random_flip" (type RandomFlip).
Rudra2307 opened this issue · 0 comments
2023-02-06 23:05:44.031991: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
File "C:\Users\rudra\OneDrive\Desktop\Projects\potato-disease-classification-main\api\main.py", line 24, in
MODEL = tf.keras.models.load_model("../saved_models/1")
File "C:\Users\rudra\OneDrive\Desktop\Projects\potato-disease-classification-main\api\env\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\rudra\OneDrive\Desktop\Projects\potato-disease-classification-main\api\env\lib\site-packages\keras\saving\legacy\saved_model\load.py", line 1015, in _unable_to_call_layer_due_to_serialization_issue
raise ValueError(
ValueError: Exception encountered when calling layer "random_flip" (type RandomFlip).
Cannot call custom layer random_flip of type <class 'keras.saving.legacy.saved_model.load.RandomFlip'>, because the call function was not serialized to the SavedModel.Please try one of the following methods to fix this issue:
(1) Implement get_config
and from_config
in the layer/model class, and pass the object to the custom_objects
argument when loading the model. For more details, see: https://www.tensorflow.org/guide/keras/save_and_serialize
(2) Ensure that the subclassed model or layer overwrites call
and not __call__
. The input shape and dtype will be automatically recorded when the object is called, and used when saving. To manually specify the input shape/dtype, decorate the call function with @tf.function(input_signature=...)
.
Call arguments received by layer "random_flip" (type RandomFlip):
• unused_args=('tf.Tensor(shape=(None, 256, 256, 3), dtype=float32)',)
• unused_kwargs={'training': 'None'}
my libs
tensorflow 2.11.0
tensorflow-estimator 2.11.0
tensorflow-intel 2.11.0
tensorflow-io-gcs-filesystem 0.30.0
tensorflow-serving-api 2.11.0
urllib3 1.26.14
uvicorn 0.20.0