首页 > 解决方案 > TensorFlow、Keras:测试图像大于训练图像

问题描述

我已经训练了一个网络来检测 14x14 像素灰度图像中的“气泡”。我用包含气泡的图像和不包含气泡的图像训练了网络。网络运行良好。

现在,我有一个带有很多气泡的大图像(我从这个大图像生成了训练数据)1

我希望网络使用 14x14 内核扫描大图像以检测气泡的位置。我怎样才能做到这一点?

下面是我的网络:

model = keras.Sequential([
    keras.layers.Flatten(input_shape=(14, 14)),
    keras.layers.Dense(128, activation=tf.nn.relu),
    keras.layers.Dense(64, activation=tf.nn.relu),
    keras.layers.Dense(32, activation=tf.nn.relu),
    keras.layers.Dense(16, activation=tf.nn.relu),
    keras.layers.Dense(8, activation=tf.nn.relu),
    keras.layers.Dense(2, activation=tf.nn.softmax)
])
model.compile(optimizer=tf.train.AdamOptimizer(), 
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

标签: imagetensorflowkeras

解决方案


I don't think you can detect the position of bubbles with the architecture you are using. You would have to adapt your case to an algorithm like YOLO: https://medium.com/@jonathan_hui/real-time-object-detection-with-yolo-yolov2-28b1b93e2088. Your output would then contain a unit indicating the presence or absence of a bubble in a particular region, and a set of units defining the coordinates of the bubbles.


推荐阅读