In [1]:
from utils2 import *


Using TensorFlow backend.
/home/quoniammm/anaconda3/envs/py3Tfgpu/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
  "This module will be removed in 0.20.", DeprecationWarning)

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]:
99

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)


Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5

In [ ]:
layer = model.get_layer('block5_conv1').output