Here is my cnn code in python:
x_train, x_valid, y_train, y_valid = train_test_split(X, Y, test_size=0.3, shuffle=True)
x_train=x_train/255. #Normalize the dataset
x_valid=x_valid/255.
model = tf.keras.models.Sequential([tf.keras.layers.Flatten(input_shape = [width, height, 3]),
tf.keras.layers.Dense(30, activation = 'relu' ),
tf.keras.layers.Dense(10, activation = 'relu' ),
tf.keras.layers.Dense(10, activation = 'relu'),
tf.keras.layers.Dense(10, activation = 'relu'),
tf.keras.layers.Dense(10, activation = 'softmax' )])
y_train=to_categorical(y_train, 10)
y_valid=to_categorical(y_valid, 10)
print(model.summary())
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=["accuracy"])
model.fit(x_train, y_train, epochs=5, verbose=1, validation_data = (x_valid, y_valid))
This is the code to get video:
cap = cv2.VideoCapture('cars.mp4')
How do I draw a bounding box? I have trained a neural network from some images. Now, using a video, I want to detect a class based on the trained neural network, how do I detect and find the bounding box coordinates?