In [1]:
from utils2 import *
In [2]:
from vgg16_avg import VGG16_Avg
In [3]:
limit_mem()
In [25]:
path = '/home/quoniammm/version-control/mine-tensorflow-examples/fastAI/deeplearning1/nbs/data/redux/sample/train/cats'
In [26]:
fnames = glob.glob(path + '/*.jpg', recursive=True)
In [28]:
n = len(fnames); n
Out[28]:
In [29]:
img = Image.open(fnames[50]); img
Out[29]:
In [30]:
rn_mean = np.array([123.68, 116.779, 103.939], dtype=np.float32)
preproc = lambda x: (x - rn_mean)[:, :, :, ::-1]
In [31]:
deproc = lambda x,s: np.clip(x.reshape(s)[:, :, :, ::-1] + rn_mean, 0, 255)
In [32]:
img_arr = preproc(np.expand_dims(np.array(img), 0))
shp = img_arr.shape
In [ ]:
model = VGG16_Avg(include_top=False)
In [ ]:
layer = model.get_layer('block5_conv1').output