在閱讀Tensorflow implmentation of VGG model時,我注意到作者對輸入的RGB圖像執行了一些縮放操作,如下圖所示。我有兩個問題:VGG_MEAN
是什麼意思,以及如何獲得該設置?其次,爲什麼我們需要減去這些平均值獲得bgr
關於運行vgg模型的圖像縮放操作
VGG_MEAN = [103.939, 116.779, 123.68]
ef build(self, rgb):
"""
load variable from npy to build the VGG
:param rgb: rgb image [batch, height, width, 3] values scaled [0, 1]
"""
start_time = time.time()
print("build model started")
rgb_scaled = rgb * 255.0
# Convert RGB to BGR
red, green, blue = tf.split(3, 3, rgb_scaled)
assert red.get_shape().as_list()[1:] == [224, 224, 1]
assert green.get_shape().as_list()[1:] == [224, 224, 1]
assert blue.get_shape().as_list()[1:] == [224, 224, 1]
bgr = tf.concat(3, [
blue - VGG_MEAN[0],
green - VGG_MEAN[1],
red - VGG_MEAN[2],
])
assert bgr.get_shape().as_list()[1:] == [224, 224, 3]
嗨喬尼,對答覆表示感謝。但原始文章中包含的原始代碼不會導入opencv。 – user288609