Professional Documents
Culture Documents
Building Computer Vision Applications Using Artificial Neural Networks, 2nd Edition Shamshad Ansari full chapter instant download
Building Computer Vision Applications Using Artificial Neural Networks, 2nd Edition Shamshad Ansari full chapter instant download
https://ebookmass.com/product/analysis-and-visualization-of-
discrete-data-using-neural-networks-koji-koyamada/
https://ebookmass.com/product/3-d-computer-vision-principles-
algorithms-and-applications-1st-edition-yu-jin-zhang/
https://ebookmass.com/product/accelerators-for-convolutional-
neural-networks-arslan-munir/
https://ebookmass.com/product/computer-vision-theory-algorithms-
practicalities-fifth-edition-davies/
AI Applications to Communications and Information
Technologies: The Role of Ultra Deep Neural Networks
Daniel Minoli
https://ebookmass.com/product/ai-applications-to-communications-
and-information-technologies-the-role-of-ultra-deep-neural-
networks-daniel-minoli/
https://ebookmass.com/product/computer-networks-global-edition-
andrew-s-tanenbaum/
https://ebookmass.com/product/probabilistic-graphical-models-for-
computer-vision-ji-q/
https://ebookmass.com/product/computer-vision-technology-for-
food-quality-evaluation-second-edition-sun/
https://ebookmass.com/product/computer-networks-and-
internets-6th-edition-ebook-pdf/
Building Computer Vision
Applications Using
Artificial Neural Networks
With Examples in OpenCV
and TensorFlow with Python
Second Edition
Shamshad Ansari
Building Computer Vision Applications Using Artificial Neural Networks: With
Examples in OpenCV and TensorFlow with Python, Second Edition
Shamshad Ansari
Centreville, VA, USA
Acknowledgments��������������������������������������������������������������������������������������������������xix
Introduction������������������������������������������������������������������������������������������������������������xxi
v
Table of Contents
Additional Libraries��������������������������������������������������������������������������������������������������������������������� 12
Installing SciPy���������������������������������������������������������������������������������������������������������������������� 12
Installing Matplotlib��������������������������������������������������������������������������������������������������������������� 12
Summary������������������������������������������������������������������������������������������������������������������������������� 12
vi
Table of Contents
vii
Table of Contents
GLCM����������������������������������������������������������������������������������������������������������������������������������� 140
HOGs������������������������������������������������������������������������������������������������������������������������������������ 145
LBP�������������������������������������������������������������������������������������������������������������������������������������� 152
Feature Selection���������������������������������������������������������������������������������������������������������������������� 159
Filter Method����������������������������������������������������������������������������������������������������������������������� 160
Wrapper Method������������������������������������������������������������������������������������������������������������������ 160
Embedded Method�������������������������������������������������������������������������������������������������������������� 161
Model Training��������������������������������������������������������������������������������������������������������������������������� 162
How to Do Machine Learning���������������������������������������������������������������������������������������������� 162
Supervised Learning������������������������������������������������������������������������������������������������������������ 163
Unsupervised Learning�������������������������������������������������������������������������������������������������������� 164
Model Deployment�������������������������������������������������������������������������������������������������������������������� 165
Summary���������������������������������������������������������������������������������������������������������������������������������� 167
viii
Table of Contents
Our First Computer Vision Model with Deep Learning: Classification of Handwritten Digits���� 207
Model Overview������������������������������������������������������������������������������������������������������������������������������������������������ 207
Model Implementation��������������������������������������������������������������������������������������������������������� 208
Model Evaluation����������������������������������������������������������������������������������������������������������������������� 217
Overfitting���������������������������������������������������������������������������������������������������������������������������� 217
Underfitting�������������������������������������������������������������������������������������������������������������������������� 219
Hyperparameters���������������������������������������������������������������������������������������������������������������������� 223
TensorBoard������������������������������������������������������������������������������������������������������������������������ 224
Experiments for Hyperparameter Tuning����������������������������������������������������������������������������� 225
Saving and Restoring Model����������������������������������������������������������������������������������������������������� 229
Save Model Checkpoints During Training���������������������������������������������������������������������������� 230
Manually Save Weights������������������������������������������������������������������������������������������������������� 233
Load the Saved Weights and Retrain the Model������������������������������������������������������������������ 233
Saving the Entire Model������������������������������������������������������������������������������������������������������ 234
Retraining the Existing Model���������������������������������������������������������������������������������������������� 234
Using a Trained Model in Applications��������������������������������������������������������������������������������� 235
Convolutional Neural Network�������������������������������������������������������������������������������������������������� 236
Architecture of CNN������������������������������������������������������������������������������������������������������������� 236
How a CNN Works���������������������������������������������������������������������������������������������������������������� 238
Summary of CNN Concepts������������������������������������������������������������������������������������������������� 243
Training a CNN Model: Pneumonia Detection from Chest X-rays���������������������������������������� 244
Examples of Popular CNNs�������������������������������������������������������������������������������������������������� 255
Summary����������������������������������������������������������������������������������������������������������������������������� 260
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
Dataset�������������������������������������������������������������������������������������������������������������������������������� 410
Downloading VGGFace2 Data���������������������������������������������������������������������������������������������� 412
Data Preparation������������������������������������������������������������������������������������������������������������������ 414
Model Training��������������������������������������������������������������������������������������������������������������������� 419
Evaluation���������������������������������������������������������������������������������������������������������������������������� 420
Developing a Real-Time Face Recognition System������������������������������������������������������������������� 421
Face Detection Model���������������������������������������������������������������������������������������������������������� 421
Classifier for Face Recognition�������������������������������������������������������������������������������������������� 422
Summary���������������������������������������������������������������������������������������������������������������������������������� 428
xii
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 513
xiii
About the Author
Shamshad Ansari is an author, inventor, and thought
leader in the fields of computer vision, machine learning,
artificial intelligence, and cognitive science. He has
extensive experience in high-scale, distributed, and parallel
computing. Sam currently serves as an adjunct professor at
George Mason University, teaching graduate-level programs
within the Data Analytics Engineering department of the
Volgenau School of Engineering. His areas of instruction
encompass machine learning, natural language processing,
and computer vision, where he imparts his knowledge and
expertise to aspiring professionals.
Having authored multiple publications on topics such as machine learning, RFID,
and high-scale enterprise computing, Sam’s contributions extend beyond academia. He
holds four US patents related to healthcare AI, showcasing his innovative mindset and
practical application of technology.
Throughout his extensive 20+ years of experience in enterprise software
development, Sam has been involved with several tech startups and early-stage
companies. He has played pivotal roles in building and expanding tech teams from
the ground up, contributing to their eventual acquisition by larger organizations.
At the beginning of his career, he worked with esteemed institutions such as the US
Department of Defense (DOD) and IBM, honing his skills and knowledge in the
industry.
Currently, Sam serves as the president and CEO of Accure, Inc., an AI company
that he founded. He is the creator and architect of, and continues to make significant
contributions to, Momentum AI, a no-code platform that encompasses data
engineering, machine learning, AI, MLOps, data warehousing, and business intelligence.
Throughout his career, Sam has made notable contributions in various domains
including healthcare, retail, supply chain, banking and finance, and manufacturing.
xv
About the Author
xvi
About the Technical Reviewers
Bharath Kumar Bolla has over 12 years of experience
and is a senior data scientist at Salesforce, Hyderabad.
Bharath obtained a master’s degree in data science from
the University of Arizona and a master’s degree in life
sciences from Mississippi State University. Bharath worked
as a research scientist for seven years at the University of
Georgia, Emory University, and Eurofins LLC. At Verizon,
Bharath led a team to build a “Smart Pricing” solution, and
at Happiest Minds, he worked on AI-based digital marketing
products. Along with his day-to-day responsibilities, Bharath is a mentor and an active
researcher with more than 20 publications in conferences and journals. Bharath received
the “40 Under 40 Data Scientists 2021” award from Analytics India Magazine for his
accomplishments.
xvii
Acknowledgments
I wrote this book with two primary objectives in mind. First, I aimed to comprehensively
construct the foundations of computer vision concepts, starting from the basics and
progressing to an advanced level. Secondly, I aspired to furnish a practical guide for
the application of these concepts in real-world computer vision systems by including
practical use cases and code examples.
Achieving these objectives required meticulous organization of topics, integration
of content with meaningful and practical use cases, and thorough testing of the code,
all of which demanded my undivided attention throughout the writing process. This
accomplishment wouldn’t have been possible without the unwavering support of my
family. My gratitude is immeasurable towards my wife, Shazia, who managed the care of
our two daughters (Erum and Dua), ensuring they remained engaged while I dedicated
myself to the writing of this book. She ingeniously transformed this experience into a
positive experience for both them and myself. Remarkably, my children began tracking
my progress, celebrating each completion of a section, subsection, or chapter. Their
enthusiasm became a wellspring of energy and motivation that significantly enriched my
writing experience. I still do not know what magic my wife used to do this.
My life is indebted to Anumati Bhagi and Ashok Bhagi, who are no less than parents
to me; their love and support always motivate me.
This book is a collection of my lifetime experiences that I gained by working with
some of the greatest engineers, data scientists, and business professionals. I would
like to thank all my colleagues at Accure and all the past companies I have worked at. I
sincerely thank all my teachers, professors, and mentors who enlightened me with their
knowledge and wisdom.
Working with the Apress editorial team, which includes remarkable individuals like
Mark Powers and Laura Berendson, has been an incredible experience. I want to extend
a special thank you to Shonmirin PA, the project coordinator, who has been instrumental
in coordinating with the editorial team and technical reviewers and providing prompt
and helpful responses to my questions along the way.
xix
Acknowledgments
xx
Introduction
For over 20 years, I have had the privilege of working with distinguished data scientists
and computer vision experts, some of the finest in their field. Throughout this journey,
I’ve gained invaluable insights, particularly in the realm of building scalable computer
vision systems following the best practices. This book encapsulates the wisdom acquired
from my work experience, as well as the collective knowledge amassed from the
exceptional individuals with whom I’ve had the fortune to work or collaborate. This book
also presents knowledge I’ve gained from the works of some of the greatest contributors
and thought leaders of computer vision. I have provided references to their work at
appropriate places throughout the book.
When I hire new engineers and scientists, one of my main challenges has been giving
them effective training so that they can quickly start contributing to the development
of computer vision systems. With numerous online resources and books available on
various computer vision topics, it’s easy to feel overwhelmed by the sheer amount of
information. This is especially true since the field of computer vision is extensive and
intricate.
In this book, my aim is to offer a structured and methodical approach to learning
computer visions systems. You will learn essential concepts first and then build on
those concepts by working through practical code examples that pertain to real-world
computer vision systems. This approach will help you connect the dots as you progress
through the chapters. I’ve structured this book to be as hands-on and practical as
possible to assist you effectively.
This book begins by explaining the core concepts of computer vision. It presents
code examples to help you understand these ideas better. In the beginning, the examples
mainly use OpenCV with the Python language.
This book also covers the basic concepts of machine learning and then gradually
moves into more complex concepts like artificial neural networks and deep learning.
Every concept is reinforced with one or more practical code examples that show how
the concept is applied in practice. Machine learning–related concepts are illustrated via
code examples in TensorFlow with Python.
xxi
Introduction
This book presents 11 examples, including working code, that demonstrate how
computer vision is used in real life. These examples are from different domains like
healthcare, surveillance, security, and manufacturing. To help you understand the code,
I explain each line step by step.
Chapters 7, 8, and 9 are dedicated to building practical computer vision–based
systems. These chapters show you all stages of how to create vision systems, from
obtaining pictures or videos, to building a data pipeline, to training a model, and finally
deploying the model for real situations.
Training state-of-the-art computer vision models requires a lot of hardware
resources. It is desirable and economically beneficial to train computer vision models on
a cloud infrastructure to leverage the latest hardware resources, such as GPUs, and pay-
as-you-go cost models. The final chapter, Chapter 10, provides step-by-step instructions
for building machine learning–based computer vision applications on three popular
cloud infrastructures: Google Cloud Platform, Amazon AWS, and Microsoft Azure.
Even though this book starts from explaining a single pixel of an image and goes up
to teaching how to use cloud computers for neural networks training, there are certain
prerequisites to better understand the concepts presented in this book. You should
already know how to use the Python programming language.
The purpose of this book is to assist working professionals, programmers, data
scientists, and even students (undergraduate and graduate) acquire hands-on skills for
building computer vision applications using artificial neural networks.
xxii
Another random document with
no related content on Scribd:
— Voi, mennään! Mennään heti paikalla! - Nanni, pane meille
puhtaat esiliinat! — intoilivat lapset.
Siitä nousi suuri ilo, hyppy ja tanssi. Annilla oli täysi työ pidättää
heitä suinpäin juoksemasta portaista alas.
*****
22
— Entä Annushka?
— En sano.
— Rupeakkin sinä meille isäksi, kun meiltä isä kuoli — sanoi pikku
Maija.
— Eipä niin. Ei ole ollut paljon aikaa kotona istuskella, mutta nyt
kai kohta jo saakin panna kaupan oven kiinni. Silloin sitä taas joutaa
kotonakin olemaan.
— Niin on tuo tyttö sitonut lastenkin suun, että eivät ole äidilleen
kertoneet, mutta kun Sannilta kuulin, katsoin velvollisuudekseni
avata silmänne.
— Äiti älä toru Nannia, älä vaan toru Nannia, me sinne kovin
tahdoimme, kun se Vanjushka on niin kiltti.
— Äiti älä vaan toru Nannia eikä meitä! Vanja on soittanut meille ja
laulanut ja tanssittanut ja leikkinyt niin, ettei kukaan muu koskaan.
Kuta enemmän hän Anni sitä asiaa ajatteli, sitä enemmän hänen
myötätuntonsa kallistui Vanjushkan puolelle, samalla kuin tuo
kapinoiva ääni emäntää vastaan tuli yhä selvemmin kuuluville. On
ilta ja lapset nukkuvat. Rouva Vuorela oli lähtenyt tuttujensa kanssa
kaupungille, Anni istui nojatuoliin ja koetti lukea.
*****
Hän oli hiipinyt sisälle hiljaa kuin varjo, mutta olihan mahdollista,
että se oli hereillä ja sittenkin kuuli.
— Olisi voita tuohon päälle, niin saattaisi sitä syödä — hän ajatteli,
mutta eihän hän ollut voita nähnytkään, sitte kun Vuorelasta lähti.
Koko syksynä ei ollut korttivoita jaettu muruakaan ja salakauppiasten
välityksellä se maksoi 16—18 mk. kilo, eihän Annin palkka sellaisiin
riittänyt.