【问题标题】:Tensorflow - Detecting multiple objects on trained softmax classification modelTensorflow - 在训练有素的 softmax 分类模型上检测多个对象
【发布时间】:2017-05-30 02:21:26
【问题描述】:

我使用标准 SVHN 裁剪数字数据集生成了一个模型,该模型可分类为 10 个可能的数字,在测试集上的准确率为 89.89%。继续前进,我想检测图像上的多个数字。 (例如汽车牌照上的号码)我该怎么做?我需要重新训练我的模型来检测多个图像吗?

#conv1
W_conv1 = weight_variable([5, 5, 1, 32])
b_conv1 = bias_variable([32])
x_image = tf.reshape(x, [-1,32,32,1])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1)

#conv2
W_conv2 = weight_variable([5, 5, 32, 64])
b_conv2 = bias_variable([64])
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)
h_pool2 = max_pool_2x2(h_conv2)

#Densely
W_fc1 = weight_variable([8 * 8 * 64, 1024])
b_fc1 = bias_variable([1024])

h_pool2_flat = tf.reshape(h_pool2, [-1, 8*8*64])
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1)

#Dropout
keep_prob = tf.placeholder(tf.float32)
h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob)

#Readout
W_fc2 = weight_variable([1024, 10])
b_fc2 = bias_variable([10])
y_conv = tf.matmul(h_fc1_drop, W_fc2) + b_fc2

#Train
cross_entropy = tf.reduce_mean(
tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y_conv))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
sess.run(tf.global_variables_initializer())
for i in range(40000):
  batch = shvn_data.nextbatch(100)
  if i%100 == 0:
    train_accuracy = accuracy.eval(feed_dict={
        x:batch[0], y_: batch[1], keep_prob: 1.0})
    print("step %d, training accuracy %f"%(i, train_accuracy))
  train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})

我的代码是从这里修改的:https://www.tensorflow.org/get_started/mnist/pros。我的代码可以在这里找到:https://github.com/limwenyao/ComputerVision/blob/testing/CNN_MNIST.py#L216

【问题讨论】:

  • 在此处添加您的代码,不要让我们关注外部链接

标签: machine-learning tensorflow deep-learning softmax


【解决方案1】:

你会在你的网周围包裹一个跨步系统。因此,您将图像与车牌一起拍摄,并将其切成许多较小的图像,然后对每个较小的图像进行数字检测并记录找到的数字,最后将它们放在一起,然后就可以看到您的车牌号了。

这种将车牌图像切割成更小的图像的过程通常也是经过训练的网络。所以你会有两个网:

  • 一个人学好剪
  • 另一个学习从每个剪切的子图像中读取一个数字

【讨论】:

    猜你喜欢
    • 2019-01-22
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    • 2019-02-04
    • 1970-01-01
    • 2020-12-22
    • 2019-04-05
    相关资源
    最近更新 更多