Skip to content

Latest commit

 

History

History
74 lines (53 loc) · 3.21 KB

02-tensorflow-keras.md

File metadata and controls

74 lines (53 loc) · 3.21 KB

8.2 TensorFlow and Keras

Slides

In the video the load_img function from Keras is imported using

from tensorflow.keras.processing.image import load_img

If the import is not working, try using

from tensorflow.keras.utils import load_img

Tensorflow documentation

Notes:

  • 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 the load_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 and blue. 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 library
  • from tensorflow import keras: to import keras
  • from tensorflow.keras.preprocessing.image import load_img: to import load_img function
  • load_img('path/to/image', targe_size=(150,150)): to load the image of 150 x 150 size in PIL format
  • np.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.

Notes

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.

Navigation