Building Computer Vision Applications Using Artificial Neural Networks: With Examples in OpenCV and TensorFlow with Python 2nd Edition Computer vision is constantly evolving, and this book has been updated to reflect new topics that have emerged in the field since the first edition’s publication.
Building Computer Vision Applications Using Artificial Neural Networks: With Examples in OpenCV and TensorFlow with Python
✍ Scribed by Shamshad Ansari
- Publisher
- Apress
- Year
- 2023
- Tongue
- English
- Leaves
- 541
- Edition
- 2
- Category
- Library
No coin nor oath required. For personal study only.
✦ Synopsis
Computer vision is constantly evolving, and this book has been updated to reflect new topics that have emerged in the field since the first edition’s publication. All code used in the book has also been fully updated.
This second edition features new material covering image manipulation practices, image segmentation, feature extraction, and object identification using real-life scenarios to help reinforce each concept. These topics are essential for building advanced computer vision applications, and you’ll gain a thorough understanding of them. The book’s source code has been updated from TensorFlow 1.x to 2.x, and includes step-by-step examples using both OpenCV and TensorFlow with Python.
Upon completing this book, you’ll have the knowledge and skills to build your own computer vision applications using neural networks
What You Will Learn
- Understand image processing, manipulation techniques, and feature extraction methods
- Work with convolutional neural networks (CNN), single-shot detector (SSD), and YOLO
- Utilize large scale model development and cloud infrastructure deployment
- Gain an overview of FaceNet neural network architecture and develop a facial recognition system
Who This Book Is For
Those who possess a solid understanding of Python programming and wish to gain an understanding of computer vision and machine learning. It will prove beneficial to data scientists, deep learning experts, and students.
✦ Table of Contents
Table of Contents
About the Author
About the Technical Reviewers
Acknowledgments
Introduction
Chapter 1: Prerequisites and Software Installation
Python and PIP
Installing Python and PIP on Ubuntu
Installing Python and PIP on macOS
Installing Python and PIP on Red Hat Linux
Installing Python and PIP on Windows
virtualenv
Installing and Activating virtualenv
TensorFlow
Installing TensorFlow on Mac with M1 Chip
Installing TensorFlow for CPUs
Installing TensorFlow for GPUs
PyCharm IDE
Installing PyCharm
Configuring PyCharm to Use virtualenv
OpenCV
Working with OpenCV
Installing OpenCV 4 with Python Bindings
Additional Libraries
Installing SciPy
Installing Matplotlib
Summary
Chapter 2: Core Concepts of Image and Video Processing
Image Processing
Image Basics
Pixels
Pixel Color
Grayscale
Color
Coordinate Systems
Using Python and OpenCV Code to Manipulate Images
Program: Loading, Exploring, and Showing an Image
Program: OpenCV Code to Access and Manipulate Pixels
Drawing
Drawing a Line on an Image
Drawing a Rectangle on an Image
Drawing a Circle on an Image
Summary
Chapter 3: Techniques of Image Processing
Transformation
Resizing
Translation
Rotation
Flipping
Cropping
Image Arithmetic and Bitwise Operations
Addition
Subtraction
Bitwise Operations
AND
OR
NOT
XOR
Masking
Splitting and Merging Channels
Noise Reduction Using Smoothing and Blurring
Mean Filtering or Averaging
Gaussian Filtering
Median Blurring
Bilateral Blurring
Binarization with Thresholding
Simple Thresholding
Adaptive Thresholding
Otsu’s Binarization
Gradients and Edge Detection
Gradient-Based Edge Detection
Sobel Derivatives (Sobel() Function)
Laplacian Derivatives (cv2.Laplacian() Function)
Canny Edge Detection
Contours
Morphological Transformation
Dilation
Erosion
Opening
Closing
Morphological Gradient
Top Hat
Black Hat
Template Matching
Template Matching with Multiple Objects
Summary
Chapter 4: Building a Machine Learning–Based Computer Vision System
Image Processing Pipeline
Feature Extraction
How to Represent Features
Color Histogram
How to Calculate a Histogram
Grayscale Histogram
RGB Color Histogram
Histogram Equalizer
GLCM
HOGs
LBP
Feature Selection
Filter Method
Wrapper Method
Embedded Method
Model Training
How to Do Machine Learning
Supervised Learning
Unsupervised Learning
Model Deployment
Summary
Chapter 5: Deep Learning and Artificial Neural Networks
Introduction to Artificial Neural Networks
Perceptron
How a Perceptron Learns
Multilayer Perceptron
What Is Deep Learning?
Deep Learning or Multilayer Perceptron Architecture
Activation Functions
Linear Activation Function
Sigmoid or Logistic Activation Function
Hyperbolic Tangent (TanH)
Rectified Linear Unit
Leaky ReLU
Scaled Exponential Linear Unit
Softplus Activation Function
Softmax
Feedforward
Error Function
Regression Loss Function
Binary Classification Loss Function
Multiclass Classification Loss Function
Optimization Algorithms
Gradient Descent
Local and Global Minima
Learning Rate
Adaptive Learning Rate
Regularization
Stochastic Gradient Descent
SGD for Distributed and Parallel Computing
SGD with Momentum
Adaptive Gradient (AdaGrad) Algorithm
Root Mean Squared Propagation (RMSProp)
Adaptive Moment (Adam)
Backpropagation
Introduction to TensorFlow
TensorFlow Installation
How to Use TensorFlow
TensorFlow Terminology
Tensor
Variable
Constant
Our First Computer Vision Model with Deep Learning: Classification of Handwritten Digits
Model Overview
Model Implementation
Model Evaluation
Overfitting
Underfitting
Evaluation Metrics
Hyperparameters
TensorBoard
Experiments for Hyperparameter Tuning
Saving and Restoring Model
Save Model Checkpoints During Training
Manually Save Weights
Load the Saved Weights and Retrain the Model
Saving the Entire Model
Retraining the Existing Model
Using a Trained Model in Applications
Convolutional Neural Network
Architecture of CNN
How a CNN Works
Convolution
Pooling/Subsampling/Downsampling
Max Pooling
Average Pooling
Summary of CNN Concepts
Training a CNN Model: Pneumonia Detection from Chest X-rays
Chest X-ray Dataset
Code Structure
CNN Model Training
Pneumonia Prediction
Examples of Popular CNNs
LeNet-5
AlexNet
VGG-16
Summary
Chapter 6: Deep Learning in Object Detection
Object Detection
Intersection over Union
Region-Based Convolutional Neural Network
Fast R-CNN
Faster R-CNN
Region Proposal Network
Fast R-CNN
Mask R-CNN
Backbone
RPN
Output Head
What Is the Significance of the Masks?
Mask R-CNN in Human Pose Estimation
Single-Shot Multibox Detection
SSD Network Architecture
Multiscale Feature Maps for Detection
Anchor Boxes and Convolutional Predictors for Detection
Default Boxes and Aspect Ratios
Training
Matching Strategy
Training Objective
Choosing Scales and Aspect Ratios for Default Boxes
Hard Negative Mining
Data Augmentation
Nonmaximum Suppression
SSD Results
YOLO
YOLO Network Design
Limitations of YOLO
YOLO9000 or YOLOv2
YOLOv3
YOLOv4
YOLOv7
YOLOv7 Architectural Features
E-ELAN
Model Scaling for Concatenation-Based Models
Planned Re-parameterized Convolution
Coarse for Auxiliary and Fine for Lead Loss
Comparison of Object Detection Algorithms
Comparison of Architecture
Comparison of Performance
Training Object Detection Model Using TensorFlow
TensorFlow on Google Colab with GPU
Accessing Google Colab
Connecting to the Hosted Runtime
Selecting a GPU Hardware Accelerator
Creating a Colab Project
Setting Up the Runtime Environment for TensorFlow and Model Training
Installing and Setting Up Libraries
Installing TensorFlow’s models Project
Downloading the Oxford-IIIT Pet Dataset
Generating TensorFlow TFRecord Files
Downloading a Pretrained Model for Transfer Learning
Configuring the Object Detection Pipeline
Executing the Model Training
Evaluating the Model
Visualizing the Training Result in TensorBoard
Exporting the TensorFlow Graph
Downloading the Object Detection Model
Detecting Objects Using Trained Models
Installing TensorFlow’s models Project
Code for Object Detection
Configuration and Initialization
Create Model Object by Loading the Trained Model
Run the Prediction and Construct the Output in a Usable Form
Write Code to Infer the Output, Draw Bounding Boxes Around Detected Objects, and Store the Result
Putting It All Together
Training a YOLOv7 Model for Object Detection
Dataset
Preparing Colab Environment
Creating the data.yaml File
Cloning YOLOv7 GitHub Repository
Training YOLOv7 Model
Launching YOLOv7 Model Training
Training on a Single GPU
Training on Multiple GPUs
Monitoring Training Progress
Monitoring Training Metrics Using TensorBoard
Inference or Object Detection Using the Training YOLOv7 Model
Exporting YOLOv7 Model to ONNX
Converting the ONNX Model to TensorFlow and TensorFlow Lite Formats
Predicting Using TensorFlow Lite Model
Summary
Chapter 7: Practical Example: Object Tracking in Videos
Preparing the Working Environment
Reading a Video Stream
Loading the Object Detection Model
Detecting Objects in Video Frames
Creating a Unique Identity for Objects Using dHash
Using the Hamming Distance to Determine Image Similarity
Object Tracking
Displaying a Live Video Stream in a Web Browser
Installing Flask
Flask Directory Structure
HTML for Displaying a Video Stream
Flask to Load the HTML Page
Flask to Serve the Video Stream
Running the Flask Server
Putting It All Together
Summary
Chapter 8: Practical Example: Face Recognition
FaceNet
FaceNet Neural Network Architecture
Input Images
Deep CNN
Face Embedding
Triplet Loss Function
Triplet Selection
Training a Face Recognition Model
Checking Out FaceNet from GitHub
Dataset
Downloading VGGFace2 Data
Data Preparation
Model Training
Evaluation
Developing a Real-Time Face Recognition System
Face Detection Model
Classifier for Face Recognition
Face Alignment
Classifier Training
Face Recognition in a Video Stream
Summary
Chapter 9: Industrial Application: Real-Time Defect Detection in Industrial Manufacturing
Real-Time Surface Defect Detection System
Dataset
Google Colab Notebook
Data Transformation
Training the SSD Model
Model Evaluation
Exporting the Model
Prediction
Real-Time Defect Detector
Image Annotations
Installing VoTT
Create Connections
Create a New Project
Create Class Labels
Label the Images
Export Labels
Summary
Chapter 10: Computer Vision Modeling on the Cloud
TensorFlow Distributed Training
What Is Distributed Training?
Data Parallelism
Model Parallelism
TensorFlow Distribution Strategy
MirroredStrategy
CentralStorageStrategy
MultiWorkerMirroredStrategy
Cluster Configuration
Dataset Sharding
Fault Tolerance
TPUStrategy
ParameterServerStrategy
OneDeviceStrategy
TF_CONFIG: TensorFlow Cluster Configuration
An Example TF_CONFIG
Example Code of Distributed Training with a Parameter Server
Steps for Running Distributed Training on the Cloud
Distributed Training on Google Cloud
Signing Up for GCP Access
Creating a Google Cloud Storage Bucket
Creating the GCS Bucket from the Web UI
Creating the GCS Bucket from the Cloud Shell
Launching GCP Virtual Machines
SSH to Log In to Each VMs
Uploading the Code for Distributed Training or Cloning the GitHub Repository
Installing Prerequisites and TensorFlow
Running Distributed Training
Distributed Training on Azure
Creating a VM with Multiple GPUs on Azure
Installing GPU Drivers and Libraries
Creating Virtual Environment and Installing TensorFlow
Implementing MirroredStrategy
Running Distributed Training
Distributed Training on AWS
Horovod
How to Use Horovod
Creating a Horovod Cluster on AWS
Horovod Cluster
Running Distributed Training
Installing Horovod
Running Horovod to Execute Distributed Training
Summary
Index
df-Capture.PNG
✦ Subjects
Computer Vision; Artificial Intelligence; TensorFlow; OpenCV; Python; Neural Network; Machine Learning; Deep Learning; Convolutional Neural Network; Recurrent Neural network
📜 SIMILAR VOLUMES
<p>Apply computer vision and machine learning concepts in developing business and industrial applications using a practical, step-by-step approach. </p> <p>The book comprises four main sections starting with setting up your programming environment and configuring your computer with all the prerequi
<p>Apply computer vision and machine learning concepts in developing business and industrial applications using a practical, step-by-step approach. </p> <p>The book comprises four main sections starting with setting up your programming environment and configuring your computer with all the prerequi
Unlocking computer vision with Python and OpenCV. Neural Network Computer Vision with OpenCV equips you with professional skills and knowledge to build intelligent vision systems using OpenCV. It creates a sequential pathway for understanding morphological operations, edge and corner detection, o
Deploy deep learning applications into production across multiple platforms. You will work on computer vision applications that use the convolutional neural network (CNN) deep learning model and Python. This book starts by explaining the traditional machine-learning pipeline, where you will analyze
<div><p>Deploy deep learning applications into production across multiple platforms. You will work on computer vision applications that use the convolutional neural network (CNN) deep learning model and Python. This book<em> </em>starts by explaining the traditional machine-learning pipeline, where