TensorFlow 2.0 Computer Vision Cookbook - Jesús Martínez - E-Book

TensorFlow 2.0 Computer Vision Cookbook E-Book

Jesús Martínez

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Computer vision is a scientific field that enables machines to identify and process digital images and videos. This book focuses on independent recipes to help you perform various computer vision tasks using TensorFlow.

The book begins by taking you through the basics of deep learning for computer vision, along with covering TensorFlow 2.x’s key features, such as the Keras and tf.data.Dataset APIs. You’ll then learn about the ins and outs of common computer vision tasks, such as image classification, transfer learning, image enhancing and styling, and object detection. The book also covers autoencoders in domains such as inverse image search indexes and image denoising, while offering insights into various architectures used in the recipes, such as convolutional neural networks (CNNs), region-based CNNs (R-CNNs), VGGNet, and You Only Look Once (YOLO).

Moving on, you’ll discover tips and tricks to solve any problems faced while building various computer vision applications. Finally, you’ll delve into more advanced topics such as Generative Adversarial Networks (GANs), video processing, and AutoML, concluding with a section focused on techniques to help you boost the performance of your networks.

By the end of this TensorFlow book, you’ll be able to confidently tackle a wide range of computer vision problems using TensorFlow 2.x.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 401

Veröffentlichungsjahr: 2021

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



TensorFlow 2.0 Computer Vision Cookbook

Implement machine learning solutions to overcome various computer vision challenges

Jesús Martínez

BIRMINGHAM—MUMBAI

TensorFlow 2.0 Computer Vision Cookbook

Copyright © 2021 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Kunal Parikh

Publishing Product Manager: Sunith Shetty

Senior Editor: David Sugarman

Content Development Editor: Nathanya Dias

Technical Editor: Arjun Varma

Copy Editor: Safis Editing

Project Coordinator: Aishwarya Mohan

Proofreader: Safis Editing

Indexer: Manju Arasan

Production Designer: Joshua Misquitta

First published: February 2021

Production reference: 1210121

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-83882-913-1

www.packt.com

Packt.com

Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionalsImprove your learning with Skill Plans built especially for youGet a free eBook or video every monthFully searchable for easy access to vital informationCopy and paste, print, and bookmark content

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

Contributors

About the author

Jesús Martínez is the founder of the computer vision e-learning site DataSmarts. He is a computer vision expert and has worked on a wide range of projects in the field, such as a piece of people-counting software fed with images coming from an RGB camera and a depth sensor, using OpenCV and TensorFlow. He developed a self-driving car in a simulation, using a convolutional neural network created with TensorFlow, that worked solely with visual inputs. Also, he implemented a pipeline that uses several advanced computer vision techniques to track lane lines on the road, as well as providing extra information such as curvature degree.

This book is dedicated to my parents, Armando and Maris, who have always pushed me toward excellence.

About the reviewers

Vincent Kok is a maker and a software platform application engineer in the transportation industry. He graduated from University of Science, Malaysia, with an MSc in embedded system engineering. Vincent actively involves himself with the developer community, as well as attending Maker Faire events held around the world, such as in Shenzhen in 2014 and in Singapore and Tokyo in 2015. Designing electronics hardware kits and giving soldering/Arduino classes for beginners are some of his favorite ways to spend his free time. Currently, his focus is on computer vision technology, software test automation, deep learning, and constantly keeping himself up to date with the latest technology.

Rajeev Ratan is a data scientist with an MSc in artificial intelligence from the University of Edinburgh and a BSc in electrical and computer engineering from the University of the West Indies. He has worked in several London tech start-ups as a data scientist, mostly in computer vision. He was a member of Entrepreneur First, a London-based start-up incubator, where he co-founded an Edtech start-up. Later on, he worked in AI tech start-ups involved in the real estate and gambling sectors. Before venturing into data science, Rajeev worked as a radio frequency engineer for 8 years. His research interests lie in deep learning and computer vision. He has created several online courses that are hosted on Udemy, Packt, and Manning Publications.

Packt is searching for authors like you

If you’re interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Preface

Chapter 1: Getting Started with TensorFlow 2.x for Computer Vision

Technical requirements

Working with the basic building blocks of the Keras API

Getting ready3

How to do it…3

How it works…6

See also7

Loading images using the Keras API

Getting ready7

How to do it…8

How it works…11

See also12

Loading images using the tf.data.Dataset API

How to do it…12

How it works…15

See also16

Saving and loading a model

How to do it…16

How it works…20

There's more…20

Visualizing a model's architecture

Getting ready20

How to do it…20

How it works…25

Creating a basic image classifier

Getting ready25

How to do it…25

How it works…32

See also32

Chapter 2: Performing Image Classification

Technical requirements

Creating a binary classifier to detect smiles

Getting ready34

How to do it…35

How it works…39

See also39

Creating a multi-class classifier to play rock paper scissors

Getting ready40

How to do it…40

How it works…44

Creating a multi-label classifier to label watches

Getting ready45

How to do it…46

How it works…51

See also52

Implementing ResNet from scratch

Getting ready52

How to do it…53

How it works…59

See also60

Classifying images with a pre-trained network using the Keras API

Getting ready60

How to do it…61

How it works…63

See also64

Classifying images with a pre-trained network using TensorFlow Hub

Getting ready64

How to do it…65

How it works…67

See also67

Using data augmentation to improve performance with the Keras API

Getting ready68

How to do it…69

How it works…75

See also75

Using data augmentation to improve performance with the tf.data and tf.image APIs

Getting ready75

How to do it…76

How it works…83

See also83

Chapter 3: Harnessing the Power of Pre-Trained Networks with Transfer Learning

Technical requirements

Implementing a feature extractor using a pre-trained network

Getting ready87

How to do it…88

How it works…93

See also94

Training a simple classifier on extracted features

Getting ready95

How to do it…95

How it works…97

See also97

Spot-checking extractors and classifiers

Getting ready98

How to do it…99

How it works…104

Using incremental learning to train a classifier

Getting ready105

How to do it…105

How it works…109

Fine-tuning a network using the Keras API

Getting ready110

How to do it…110

How it works…114

See also115

Fine-tuning a network using TFHub

Getting ready115

How to do it…116

How it works…119

See also119

Chapter 4: Enhancing and Styling Images with DeepDream, Neural Style Transfer, and Image Super-Resolution

Technical requirements

Implementing DeepDream

Getting ready123

How to do it…123

How it works…127

See also128

Generating your own dreamy images

Getting ready128

How to do it…129

How it works…133

Implementing Neural Style Transfer

Getting ready134

How to do it…134

How it works…140

See also141

Applying style transfer to custom images

Getting ready141

How to do it…142

How it works…146

See also146

Applying style transfer with TFHub

Getting ready147

How to do it…147

How it works…151

See also151

Improving image resolution with deep learning

Getting ready152

How to do it…152

How it works…159

See also159

Chapter 5: Reducing Noise with Autoencoders

Technical requirements

Creating a simple fully connected autoencoder

Getting ready162

How to do it…163

How it works…167

See also168

Creating a convolutional autoencoder

Getting ready168

How to do it…168

How it works…174

See also175

Denoising images with autoencoders

Getting ready175

How to do it…175

How it works…181

Spotting outliers using autoencoders

Getting ready182

How to do it…182

How it works…187

Creating an inverse image search index with deep learning

Getting ready188

How to do it…188

How it works…193

See also194

Implementing a variational autoencoder

Getting ready194

How to do it…194

How it works…201

See also201

Chapter 6: Generative Models and Adversarial Attacks

Technical requirements

Implementing a deep convolutional GAN

Getting ready205

How to do it…205

How it works…212

See also213

Using a DCGAN for semi-supervised learning

Getting ready213

How to do it…213

How it works…221

See also222

Translating images with Pix2Pix

Getting ready222

How to do it…223

How it works…235

See also236

Translating unpaired images with CycleGAN

Getting ready236

How to do it…237

How it works…251

See also251

Implementing an adversarial attack using the Fast Gradient Signed Method

Getting ready252

How to do it252

How it works…256

See also256

Chapter 7: Captioning Images with CNNs and RNNs

Technical requirements

Implementing a reusable image caption feature extractor

Getting ready259

How to do it…259

How it works…267

See also268

Implementing an image captioning network

Getting ready268

How to do it…269

How it works…276

See also277

Generating captions for your own photos

Getting ready278

How to do it…278

How it works…283

Implementing an image captioning network on COCO with attention

Getting ready284

How to do it…284

Chapter 8: Fine-Grained Understanding of Images through Segmentation

Technical requirements

Creating a fully convolutional network for image segmentation

Getting ready304

How to do it…305

How it works…318

See also319

Implementing a U-Net from scratch

Getting ready319

How to do it…320

How it works…331

See also331

Implementing a U-Net with transfer learning

Getting ready332

How to do it…333

How it works…343

See also344

Segmenting images using Mask-RCNN and TensorFlow Hub

Getting ready344

How to do it…345

How it works…349

See also350

Chapter 9: Localizing Elements in Images with Object Detection

Technical requirements

Creating an object detector with image pyramids and sliding windows

Getting ready353

How to do it…353

How it works…361

See also361

Detecting objects with YOLOv3

Getting ready362

How it works…378

See also378

Training your own object detector with TensorFlow's Object Detection API

Getting ready379

How to do it…380

How it works…390

See also391

Detecting objects using TFHub

Getting ready392

How to do it…392

How it works…396

See also396

Chapter 10: Applying the Power of Deep Learning to Videos

Technical requirements

Detecting emotions in real time

Getting ready398

How to do it…399

How it works…412

See also412

Recognizing actions with TensorFlow Hub

Getting ready413

How to do it…413

How it works…418

See also419

Generating the middle frames of a video with TensorFlow Hub

Getting ready420

How to do it…420

How it works…424

See also425

Performing text-to-video retrieval with TensorFlow Hub

Getting ready425

How to do it…426

How it works…432

See also432

Chapter 11: Streamlining Network Implementation with AutoML

Technical requirements

Creating a simple image classifier with AutoKeras

How to do it…435

How it works…436

See also436

Creating a simple image regressor with AutoKeras

Getting ready437

How to do it…437

How it works…440

See also441

Exporting and importing a model in AutoKeras

How to do it…441

How it works…444

See also445

Controlling architecture generation with AutoKeras' AutoModel

How to do it…445

How it works…449

See also449

Predicting age and gender with AutoKeras

Getting ready450

How to do it…452

How it works…459

See also460

Chapter 12: Boosting Performance

Technical requirements

Using convolutional neural network ensembles to improve accuracy

Getting ready462

How to do it…463

How it works…469

See also470

Using test time augmentation to improve accuracy

Getting ready470

How to do it…471

How it works…476

Using rank-N accuracy to evaluate performance

Getting ready477

How to do it…478

How it works…483

See also483

Using label smoothing to increase performance

Getting ready484

How to do it…484

How it works…489

Checkpointing model

How to do it…490

Customizing the training process using tf.GradientTape

How to do it…497

How it works…501

Getting ready502

How to do it…502

How it works…507

See also507

Other Books You May Enjoy