【问题标题】:How to detect an object and draw a bounding box based on cnn如何基于cnn检测物体并绘制边界框
【发布时间】:2022-01-05 22:01:20
【问题描述】:

这是我在 python 中的 cnn 代码:

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))

这是获取视频的代码:

cap = cv2.VideoCapture('cars.mp4')

如何绘制边界框?我已经从一些图像中训练了一个神经网络。现在,使用一个视频,我想检测一个基于训练好的神经网络的类,我如何检测并找到边界框坐标?

【问题讨论】:

  • 你不能用那个模型来做。没你想的那么容易,你需要搜索一下物体检测。

标签: python-3.x opencv conv-neural-network object-detection bounding-box


【解决方案1】:

为什么不应该使用 Yolo 和 tensorflow object detection 这样的预训练模型?

这个博客会帮助你。试试这个

YOLO object detection with OpenCV

【讨论】:

    猜你喜欢
    • 2019-06-23
    • 2018-06-03
    • 2021-03-17
    • 2017-11-16
    • 2020-11-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多