Wednesday, May 3, 2017

Keras: installation with Tensorflow and opencv

$ mkvirtualenv keras_tf
$ workon keras_tf

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl
#$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0rc2-py2-none-any.whl
wheel name should come from
linklink

$ pip install --upgrade $TF_BINARY_URL


$ pip install numpy scipy
$ pip install scikit-learn
$ pip install pillow

$ pip install h5py


$ pip install keras

Before we get too far we should check the contents of our keras.json  configuration file. You can find this file in ~/.keras/keras.json .

$gedit ~/.keras/keras.json .

add  "image_dim_ordering": "tf" in the file and file contents should look lik


{
    "image_dim_ordering": "tf",
    "epsilon": 1e-07,
    "floatx": "float32",
    "backend": "tensorflow"
}


You might be wondering what exactly image_dim_ordering  controls.
Using TensorFlow, images are represented as NumPy arrays with the shape (height, width, depth), where the depth is the number of channels in the image.
However, if you are using Theano, images are instead assumed to be represented as (depth, height, width).

Find CV2.so
$ cd /
$ sudo find . -name '*cv2.so*'
./Users/adrianrosebrock/.virtualenvs/cv/lib/python2.7/site-packages/cv2.so
./Users/adrianrosebrock/.virtualenvs/gurus/lib/python2.7/site-packages/cv2.so
./Users/adrianrosebrock/.virtualenvs/keras_th/lib/python2.7/site-packages/cv2.so
./usr/local/lib/python2.7/site-packages/cv2.so

and copy that to virtual environment


$ cd ~/.virtualenvs/keras_tf/lib/python2.7/site-packages/
$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
$ cd ~

------------------------------------------------

References
Content taken from


No comments:

Post a Comment