@Fareed_Ahmad, I removed your code since it is against community guidelines to share your code here.
I didn’t notice anything that stood out in the code you shared that would cause the error you’re seeing, though. To debug, expand the 4 frames to see which line in define_and_compile_model() is causing the error. The error you’re getting is that the inputs to the layer aren’t right, so narrow down on the line that is causing the problem to see what could be causing that error.
Yeah you have a problem with the bounding_box_regression_ouput layer. This output is supposed to give you numerical range coordinates and I leave it to you to find where the simple mistake is!
in
1 # define your model
----> 2 model = define_and_compile_model()
3 # print model layers
4 model.summary()
4 frames
in define_and_compile_model()
8
9 # create the model
—> 10 model = final_model(inputs)
11
12 # compile your model
in final_model(inputs)
9
10 # bounding box
—> 11 bounding_box_output = bounding_box_regression(last_dense_layer)
12
13 # define the TensorFlow Keras model using the inputs and outputs to your model
in bounding_box_regression(x)
3
4 # Dense layer named bounding_box
----> 5 bounding_box_regression_output = tf.keras.layers.Dense(4, name=‘bounding_box’)(x)
6 ### END CODE HERE ###
7
/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
—> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb
/usr/local/lib/python3.8/dist-packages/keras/engine/input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name)
195 # have a shape attribute.
196 if not hasattr(x, ‘shape’):
→ 197 raise TypeError(f’Inputs to a layer should be tensors. Got: {x}')
198
199 if len(inputs) != len(input_spec):
TypeError: Inputs to a layer should be tensors. Got: <keras.layers.core.dense.Dense object at 0x7fb215e8a730>