img =/ 255.0
from [0, 255] to [0, 1.0]
均值:0.229
最大:0.9999
最小:0.0
Vgg16 能识别的类别,查看:
synset.txt
填充法实现代码:
def fill_image(img):
h = img.shape[0]
w = img.shape[1]
is_trans = 0
if h>w:
is_trans = 1
img = img.transpose((1,0,2))
h = img.shape[0]
w = img.shape[1]
assert( w>=h )
im_add = np.zeros( (int( (w-h)/2 ), w, 3) )
if is_trans:
return np.concatenate( (im_add, img, im_add) ).transpose((1,0,2))
else:
return np.concatenate( (im_add, img, im_add) )
def fill_image2(img, w_target, h_target):
w_t, h_t = w_target, h_target
h = img.shape[0]
w = img.shape[1]
assert( w_t >= w )
assert( h_t >= h )
im_add = np.zeros( (h, int( (w_t-w)/2 ), 3) )
img = np.concatenate( (im_add, img, im_add), axis=1 )
im_add = np.zeros( (int( (h_t-h)/2 ), w_t, 3) )
img = np.concatenate( (im_add, img, im_add) )
return img
图像填充:0.8344192,图像剪切:0.8326041
图像填充:0.89500195,图像剪切:0.871053
图像填充:0.8256433,图像剪切:0.78070647
图像填充:0.8568995,图像剪切:0.7757687
墨之科技,版权所有 © Copyright 2017-2027
湘ICP备14012786号 邮箱:ai@inksci.com