- TensorFlow is a library to train deep learning models and Keras is higher level abstraction on the top of TensorFlow. Keras used to be separate library but from tensorflow 2+ version, keras became part of the tensorflow library. The libraries can be installed using
pip install tensorflow
(for CPU and GPU). However, additional setup is required to integrate TensorFlow with GPU. - Neural networks expect an image of a certain size, therefore, we need to provide the image size in
target_size
parameter of theload_img
function. - Each image consists of pixel and each of these pixels has the shape of 3 dimensions (height, width, color channels)
- A typical color image consists of three color channels:
red
,green
andblue
. Each color channel has 8 bits or 1 byte and can represent distinct values between 0-256 (uint8 type).
Classes, functions, and methods:
import tensorflow as tf
: to import tensorflow libraryfrom tensorflow import keras
: to import kerasfrom tensorflow.keras.preprocessing.image import load_img
: to import load_img functionload_img('path/to/image', targe_size=(150,150))
: to load the image of 150 x 150 size in PIL formatnp.array(img)
: convert image into a numpy array of 3D shape, where each row of the array represents the value of red, green, and blue color channels of one pixel in the image.
Add notes from the video (PRs are welcome)
- tensorflow and keras as deep learning libraries
- end-to-end open source machine learning framework
- tensorflow as library for training deep learning models
- keras as high-level abstraction on top of tensorflow
- installing tensorflow
- local vs cloud configuration
- loading and preprocessing images
- keras is part of tensorflow since version 2.0
- working with different image sizes
- processing images using the python pillow library
- encoding images as numpy arrays
- image size (i.e. 150 x 150 pixels) multiplied by number of colors (i.e. RGB) equals shape of array
- numpy array dtype as unsigned int8 (uint8) which includes the range from 0 to 255
The notes are written by the community. If you see an error here, please create a PR with a fix. |