小编R.i*_*go 的帖子

关于使用 tf.image.crop_and_resize

我正在研究适用于 fast-rcnn 的 ROI 池化层,我习惯于使用 tensorflow。我发现tf.image.crop_and_resize可以作为 ROI 池化层。

但是我尝试了很多次都没有得到我期望的结果。或者真正的结果是否正是我得到的?

这是我的代码

import cv2
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt 

img_path = r'F:\IMG_0016.JPG'
img = cv2.imread(img_path)
img = img.reshape([1,580,580,3])
img = img.astype(np.float32)
#img = np.concatenate([img,img],axis=0)

img_ = tf.Variable(img) # img shape is [580,580,3]
boxes = tf.Variable([[100,100,300,300],[0.5,0.1,0.9,0.5]])
box_ind = tf.Variable([0,0])
crop_size = tf.Variable([100,100])

#b = tf.image.crop_and_resize(img,[[0.5,0.1,0.9,0.5]],[0],[50,50])
c = tf.image.crop_and_resize(img_,boxes,box_ind,crop_size)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
a = c.eval(session=sess)

plt.imshow(a[0])
plt.imshow(a[1])
Run Code Online (Sandbox Code Playgroud)

我提交了我的原点img和结果:a0 , a1
如果我错了有人能教我如何使用这个功能吗?谢谢。

machine-learning tensorflow

4
推荐指数
1
解决办法
6205
查看次数

标签 统计

machine-learning ×1

tensorflow ×1