Table of Contents
Preface xxiii
 Part I Introduction
 Chapter 1 Introduction to AI 3
 1.1 What Is AI? 3
 1.2 The History of AI 5
 1.3 AI Hypes and AI Winters 9
 1.4 The Types of AI 11
 1.5 Edge AI and Cloud AI 12
 1.6 Key Moments of AI 14
 1.7 The State of AI 17
 1.8 AI Resources 19
 1.9 Summary 21
 1.10 Chapter Review Questions 22
 Chapter 2 AI Development Tools 23
 2.1 AI Hardware Tools 23
 2.2 AI Software Tools 24
 2.3 Introduction to Python 27
 2.4 Python Development Environments 30
 2.4 Getting Started with Python 34
 2.5 AI Datasets 45
 2.6 Python AI Frameworks 47
 2.7 Summary 49
 2.8 Chapter Review Questions 50
 Part II Machine Learning and Deep Learning
 Chapter 3 Machine Learning 53
 3.1 Introduction 53
 3.2 Supervised Learning: Classifications 55
 Scikit-Learn Datasets 56
 Support Vector Machines 56
 Naive Bayes 67
 Linear Discriminant Analysis 69
 Principal Component Analysis 70
 Decision Tree 73
 Random Forest 76
 K-Nearest Neighbors 77
 Neural Networks 78
 3.3 Supervised Learning: Regressions 80
 3.4 Unsupervised Learning 89
 K-means Clustering 89
 3.5 Semi-supervised Learning 91
 3.6 Reinforcement Learning 93
 Q-Learning 95
 3.7 Ensemble Learning 102
 3.8 AutoML 106
 3.9 PyCaret 109
 3.10 LazyPredict 111
 3.11 Summary 115
 3.12 Chapter Review Questions 116
 Chapter 4 Deep Learning 117
 4.1 Introduction 117
 4.2 Artificial Neural Networks 120
 4.3 Convolutional Neural Networks 125
 4.3.1 LeNet, AlexNet, GoogLeNet 129
 4.3.2 VGG, ResNet, DenseNet, MobileNet, EffecientNet, and YOLO 140
 4.3.3 U-Net 152
 4.3.4 AutoEncoder 157
 4.3.5 Siamese Neural Networks 161
 4.3.6 Capsule Networks 163
 4.3.7 CNN Layers Visualization 165
 4.4 Recurrent Neural Networks 173
 4.4.1 Vanilla RNNs 175
 4.4.2 Long-Short Term Memory 176
 4.4.3 Natural Language Processing and Python Natural Language Toolkit 183
 4.5 Transformers 187
 4.5.1 BERT and ALBERT 187
 4.5.2 GPT-3 189
 4.5.3 Switch Transformers 190
 4.6 Graph Neural Networks 191
 4.6.1 SuperGLUE 192
 4.7 Bayesian Neural Networks 192
 4.8 Meta Learning 195
 4.9 Summary 197
 4.10 Chapter Review Questions 197
 Part III AI Applications
 Chapter 5 Image Classification 201
 5.1 Introduction 201
 5.2 Classification with Pre-trained Models 203
 5.3 Classification with Custom Trained Models: Transfer Learning 209
 5.4 Cancer/Disease Detection 227
 5.4.1 Skin Cancer Image Classification 227
 5.4.2 Retinopathy Classification 229
 5.4.3 Chest X-Ray Classification 230
 5.4.5 Brain Tumor MRI Image Classification 231
 5.4.5 RSNA Intracranial Hemorrhage Detection 231
 5.5 Federated Learning for Image Classification 232
 5.6 Web-Based Image Classification 233
 5.6.1 Streamlit Image File Classification 234
 5.6.2 Streamlit Webcam Image Classification 242
 5.6.3 Streamlit from GitHub 248
 5.6.4 Streamlit Deployment 249
 5.7 Image Processing 250
 5.7.1 Image Stitching 250
 5.7.2 Image Inpainting 253
 5.7.3 Image Coloring 255
 5.7.4 Image Super Resolution 256
 5.7.5 Gabor Filter 257
 5.8 Summary 262
 5.9 Chapter Review Questions 263
 Chapter 6 Face Detection and Face Recognition 265
 6.1 Introduction 265
 6.2 Face Detection and Face Landmarks 266
 6.3 Face Recognition 279
 6.3.1 Face Recognition with Face_Recognition 279
 6.3.2 Face Recognition with OpenCV 285
 6.3.3 GUI-Based Face Recognition System 288
 Other GUI Development Libraries 300
 6.3.4 Google FaceNet 301
 6.4 Age, Gender, and Emotion Detection 301
 6.4.1 DeepFace 302
 6.4.2 TCS-HumAIn-2019 305
 6.5 Face Swap 309
 6.5.1 Face_Recognition and OpenCV 310
 6.5.2 Simple_Faceswap 315
 6.5.3 DeepFaceLab 322
 6.6 Face Detection Web Apps 322
 6.7 How to Defeat Face Recognition 334
 6.8 Summary 335
 6.9 Chapter Review Questions 336
 Chapter 7 Object Detections and Image Segmentations 337
 7.1 Introduction 337
 R-CNN Family 338
 YOLO 339
 SSD 340
 7.2 Object Detections with Pretrained Models 341
 7.2.1 Object Detection with OpenCV 341
 7.2.2 Object Detection with YOLO 346
 7.2.3 Object Detection with OpenCV and Deep Learning 351
 7.2.4 Object Detection with TensorFlow, ImageAI, Mask RNN, PixelLib, Gluon 354
 TensorFlow Object Detection 354
 ImageAI Object Detection 355
 MaskRCNN Object Detection 357
 Gluon Object Detection 363
 7.2.5 Object Detection with Colab OpenCV 364
 7.3 Object Detections with Custom Trained Models 369
 7.3.1 OpenCV 369
 Step 1 369
 Step 2 369
 Step 3 369
 Step 4 370
 Step 5 371
 7.3.2 YOLO 372
 Step 1 372
 Step 2 372
 Step 3 373
 Step 4 375
 Step 5 375
 7.3.3 TensorFlow, Gluon, and ImageAI 376
 TensorFlow 376
 Gluon 376
 ImageAI 376
 7.4 Object Tracking 377
 7.4.1 Object Size and Distance Detection 377
 7.4.2 Object Tracking with OpenCV 382
 Single Object Tracking with OpenCV 382
 Multiple Object Tracking with OpenCV 384
 7.4.2 Object Tracking with YOLOv4 and DeepSORT 386
 7.4.3 Object Tracking with Gluon 389
 7.5 Image Segmentation 389
 7.5.1 Image Semantic Segmentation and Image Instance Segmentation 390
 PexelLib 390
 Detectron2 394
 Gluon CV 394
 7.5.2 K-means Clustering Image Segmentation 394
 7.5.3 Watershed Image Segmentation 396
 7.6 Background Removal 405
 7.6.1 Background Removal with OpenCV 405
 7.6.2 Background Removal with PaddlePaddle 423
 7.6.3 Background Removal with PixelLib 425
 7.7 Depth Estimation 426
 7.7.1 Depth Estimation from a Single Image 426
 7.7.2 Depth Estimation from Stereo Images 428
 7.8 Augmented Reality 430
 7.9 Summary 431
 7.10 Chapter Review Questions 431
 Chapter 8 Pose Detection 433
 8.1 Introduction 433
 8.2 Hand Gesture Detection 434
 8.2.1 OpenCV 434
 8.2.2 TensorFlow.js 452
 8.3 Sign Language Detection 453
 8.4 Body Pose Detection 454
 8.4.1 OpenPose 454
 8.4.2 OpenCV 455
 8.4.3 Gluon 455
 8.4.4 PoseNet 456
 8.4.5 ML5JS 457
 8.4.6 MediaPipe 459
 8.5 Human Activity Recognition 461
 ActionAI 461
 Gluon Action Detection 461
 Accelerometer Data HAR 461
 8.6 Summary 464
 8.7 Chapter Review Questions 464
 Chapter 9 GAN and Neural-Style Transfer 465
 9.1 Introduction 465
 9.2 Generative Adversarial Network 466
 9.2.1 CycleGAN 467
 9.2.2 StyleGAN 469
 9.2.3 Pix2Pix 474
 9.2.4 PULSE 475
 9.2.5 Image Super-Resolution 475
 9.2.6 2D to 3D 478
 9.3 Neural-Style Transfer 479
 9.4 Adversarial Machine Learning 484
 9.5 Music Generation 486
 9.6 Summary 489
 9.7 Chapter Review Questions 489
 Chapter 10 Natural Language Processing 491
 10.1 Introduction 491
 10.1.1 Natural Language Toolkit 492
 10.1.2 spaCy 493
 10.1.3 Gensim 493
 10.1.4 TextBlob 494
 10.2 Text Summarization 494
 10.3 Text Sentiment Analysis 508
 10.4 Text/Poem Generation 510
 10.5.1 Text to Speech 515
 10.5.2 Speech to Text 517
 10.6 Machine Translation 522
 10.7 Optical Character Recognition 523
 10.8 QR Code 524
 10.9 PDF and DOCX Files 527
 10.10 Chatbots and Question Answering 530
 10.10.1 ChatterBot 530
 10.10.2 Transformers 532
 10.10.3 J.A.R.V.I.S. 534
 10.10.4 Chatbot Resources and Examples 540
 10.11 Summary 541
 10.12 Chapter Review Questions 542
 Chapter 11 Data Analysis 543
 11.1 Introduction 543
 11.2 Regression 544
 11.2.1 Linear Regression 545
 11.2.2 Support Vector Regression 547
 11.2.3 Partial Least Squares Regression 554
 11.3 Time-Series Analysis 563
 11.3.1 Stock Price Data 563
 11.3.2 Stock Price Prediction 565
 Streamlit Stock Price Web App 569
 11.3.4 Seasonal Trend Analysis 573
 11.3.5 Sound Analysis 576
 11.4 Predictive Maintenance Analysis 580
 11.5 Anomaly Detection and Fraud Detection 584
 11.5.1 Numenta Anomaly Detection 584
 11.5.2 Textile Defect Detection 584
 11.5.3 Healthcare Fraud Detection 584
 11.5.4 Santander Customer Transaction Prediction 584
 11.6 COVID-19 Data Visualization and Analysis 585
 11.7 KerasClassifier and KerasRegressor 588
 11.7.1 KerasClassifier 589
 11.7.2 KerasRegressor 593
 11.8 SQL and NoSQL Databases 599
 11.9 Immutable Database 608
 11.9.1 Immudb 608
 11.9.2 Amazon Quantum Ledger Database 609
 11.10 Summary 610
 11.11 Chapter Review Questions 610
 Chapter 12 Advanced AI Computing 613
 12.1 Introduction 613
 12.2 AI with Graphics Processing Unit 614
 12.3 AI with Tensor Processing Unit 618
 12.4 AI with Intelligence Processing Unit 621
 12.5 AI with Cloud Computing 622
 12.5.1 Amazon AWS 623
 12.5.2 Microsoft Azure 624
 12.5.3 Google Cloud Platform 625
 12.5.4 Comparison of AWS, Azure, and GCP 625
 12.6 Web-Based AI 629
 12.6.1 Django 629
 12.6.2 Flask 629
 12.6.3 Streamlit 634
 12.6.4 Other Libraries 634
 12.7 Packaging the Code 635
 Pyinstaller 635
 Nbconvert 635
 Py2Exe 636
 Py2app 636
 Auto-Py-To-Exe 636
 cx_Freeze 637
 Cython 638
 Kubernetes 639
 Docker 642
 PIP 647
 12.8 AI with Edge Computing 647
 12.8.1 Google Coral 647
 12.8.2 TinyML 648
 12.8.3 Raspberry Pi 649
 12.9 Create a Mobile AI App 651
 12.10 Quantum AI 653
 12.11 Summary 657
 12.12 Chapter Review Questions 657
 Index 659