簡體   English   中英

使用Inception V3在Tensorflow中定位對象

[英]localising objects in Tensorflow using inception V3

我看過這篇博客文章,描述了如何使用Google的圖像分類模型Inception V3在圖像中定位對象。

“我們可以將8x8x2048表示形式解釋為特征網格,將圖像分解為8個水平和8個垂直網格正方形。”

誰能解釋我如何在python中訪問Inception的8x8x2048層? 然后使用1x1卷積將這些向量的每一個映射到類標簽?

謝謝!

tensorflow回購中inception模型調用了inception.slim.inception_v3函數,您需要在此處修改網絡以為1x1卷積增加一層。

更改將非常小,您可以按照其構造其他層的方式進行操作。 為簡單起見,該層類似於:

net = ops.conv2d(net, 2048, [1, 1])

我發現你可以得到8x8x2048

    with tf.Session(config=config) as sess:
        tensor = sess.graph.get_tensor_by_name('mixed_10/join:0')
        for image_to_test in os.listdir(directory):
            image = os.path.join(directory, image_to_test)
            with tf.gfile.FastGFile(image, 'rb') as f:
                image_data = f.read()
                decoded={'DecodeJpeg/contents:0': image_data}
                predictions = sess.run(tensor, decoded)

預測現在具有8x8x2048

但是我還沒有弄清楚如何從“ 2048”值中獲取一個類

我在嘗試

import tensorflow.contrib.slim as slim

predictions = sess.run(tensor, decoded)
ppp= slim.conv2d(predictions,2048,[1,1])
x=tf.unstack(ppp)

但這會返回張量

Tensor(“ Conv / Relu:0”,shape =(1,8,8,2048),dtype = float32,device = / device:CPU:0)

[<tf.Tensor'unstack:0'shape =(8,8,2048)dtype = float32>]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM