Hands-On Computer Vision with Detectron2

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Explore Detectron2 using cutting-edge models and learn all about implementing future computer vision applications in custom domains Purchase of the print or Kindle book includes a free PDF eBook Key Features Learn how to tackle common computer vision tasks in modern businesses with Detectron2 Leverage Detectron2 performance tuning techniques to control the model's finest details Deploy Detectron2 models into production and develop Detectron2 models for mobile devices Book Description Computer vision is a crucial component of many modern businesses, including automobiles, robotics, and manufacturing, and its market is growing rapidly. This book helps you explore Detectron2, Facebook's next-gen library providing cutting-edge detection and segmentation algorithms. It's used in research and practical projects at Facebook to support computer vision tasks, and its models can be exported to TorchScript or ONNX for deployment. The book provides you with step-by-step guidance on using existing models in Detectron2 for computer vision tasks (object detection, instance segmentation, key-point detection, semantic detection, and panoptic segmentation). You'll get to grips with the theories and visualizations of Detectron2's architecture and learn how each module in Detectron2 works. As you advance, you'll build your practical skills by working on two real-life projects (preparing data, training models, fine-tuning models, and deployments) for object detection and instance segmentation tasks using Detectron2. Finally, you'll deploy Detectron2 models into production and develop Detectron2 applications for mobile devices. By the end of this deep learning book, you'll have gained sound theoretical knowledge and useful hands-on skills to help you solve advanced computer vision tasks using Detectron2. What you will learn Build computer vision applications using existing models in Detectron2 Grasp the concepts underlying Detectron2's architecture and components Develop real-life projects for object detection and object segmentation using Detectron2 Improve model accuracy using Detectron2's performance-tuning techniques Deploy Detectron2 models into server environments with ease Develop and deploy Detectron2 models into browser and mobile environments Who this book is for If you are a deep learning application developer, researcher, or software developer with some prior knowledge about deep learning, this book is for you to get started and develop deep learning models for computer vision applications. Even if you are an expert in computer vision and curious about the features of Detectron2, or you would like to learn some cutting-edge deep learning design patterns, you will find this book helpful. Some HTML, Android, and C++ programming skills are advantageous if you want to deploy computer vision applications using these platforms.

Author(s): Van Vung Pham
Publisher: Packt Publishing Pvt Ltd
Year: 2023

Language: English
Pages: 318

Hands-On Computer Vision with Detectron2
Foreword
Contributors
About the author
About the reviewers
Preface

Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Code in Action
Conventions used
Get in touch
Share Your Thoughts
Download a free PDF copy of this book

Part 1: Introduction to Detectron2
Chapter 1: An Introduction to Detectron2 and Computer Vision Tasks

Technical requirements
Computer vision tasks
Object detection
Instance segmentation
Keypoint detection
Semantic segmentation
Panoptic segmentation
An introduction to Detectron2 and its architecture
Introducing Detectron2
Detectron2 architecture
Detectron2 development environments
Cloud development environment for Detectron2 applications
Local development environment for Detectron2 applications
Connecting Google Colab to a local development environment
Summary

Chapter 2: Developing Computer Vision Applications Using Existing Detectron2 Models

Technical requirements
Introduction to Detectron2’s Model Zoo
Developing an object detection application
Getting the configuration file
Getting a predictor
Performing inferences
Visualizing the results
Developing an instance segmentation application
Selecting a configuration file
Getting a predictor
Performing inferences
Visualizing the results
Developing a keypoint detection application
Selecting a configuration file
Getting a predictor
Performing inferences
Visualizing the results
Developing a panoptic segmentation application
Selecting a configuration file
Getting a predictor
Performing inferences
Visualizing the results
Developing a semantic segmentation application
Selecting a configuration file and getting a predictor
Performing inferences
Visualizing the results
Putting it all together
Getting a predictor
Performing inferences
Visualizing the results
Performing a computer vision task
Summary

Part 2: Developing Custom Object Detection Models
Chapter 3: Data Preparation for Object Detection Applications

Technical requirements
Common data sources
Getting images
Selecting an image labeling tool
Annotation formats
Labeling the images
Annotation format conversions
Converting YOLO datasets to COCO datasets
Converting Pascal VOC datasets to COCO datasets
Summary

Chapter 4: The Architecture of the Object Detection Model in Detectron2

Technical requirements
Introduction to the application architecture
The backbone network
Region Proposal Network
The anchor generator
The RPN head
The RPN loss calculation
Proposal predictions
Region of Interest Heads
The pooler
The box predictor
Summary

Chapter 5: Training Custom Object Detection Models

Technical requirements
Processing data
The dataset
Downloading and performing initial explorations
Data format conversion
Displaying samples
Using the default trainer
Selecting the best model
Evaluation metrics for object detection models
Selecting the best model
Inferencing thresholds
Sample predictions
Developing a custom trainer
Utilizing the hook system
Summary

Chapter 6: Inspecting Training Results and Fine-Tuning Detectron2’s Solvers

Technical requirements
Inspecting training histories with TensorBoard
Understanding Detectron2’s solvers
Gradient descent
Stochastic gradient descent
Momentum
Variable learning rates
Fine-tuning the learning rate and batch size
Summary

Chapter 7: Fine-Tuning Object Detection Models

Technical requirements
Setting anchor sizes and anchor ratios
Preprocessing input images
Sampling training data and generating the default anchors
Generating sizes and ratios hyperparameters
Setting pixel means and standard deviations
Preparing a data loader
Calculating the running means and standard deviations
Putting it all together
Summary

Chapter 8: Image Data Augmentation Techniques

Technical requirements
Image augmentation techniques
Why image augmentations?
What are image augmentations?
How to perform image augmentations
Detectron2’s image augmentation system
Transformation classes
Augmentation classes
The AugInput class
Summary

Chapter 9: Applying Train-Time and Test-Time Image Augmentations

Technical requirements
The Detectron2 data loader
Applying existing image augmentation techniques
Developing custom image augmentation techniques
Modifying the existing data loader
Developing the MixUp image augmentation technique
Developing the Mosaic image augmentation technique
Applying test-time image augmentation techniques
Summary

Part 3: Developing a Custom Detectron2 Model for Instance Segmentation Tasks
Chapter 10: Training Instance Segmentation Models

Technical requirements
Preparing data for training segmentation models
Getting images, labeling images, and converting annotations
Introduction to the brain tumor segmentation dataset
The architecture of the segmentation models
Training custom segmentation models
Summary

Chapter 11: Fine-Tuning Instance Segmentation Models

Technical requirements
Introduction to PointRend
Using existing PointRend models
Training custom PointRend models
Summary

Part 4: Deploying Detectron2 Models into Production
Chapter 12: Deploying Detectron2 Models into Server Environments

Technical requirements
Supported file formats and runtimes
Development environments, file formats, and runtimes
Exporting PyTorch models using the tracing method
When the tracing method fails
Exporting PyTorch models using the scripting method
Mixing tracing and scripting approaches
Deploying models using a C++ environment
Deploying custom Detectron2 models
Detectron2 utilities for exporting models
Exporting a custom Detectron2 model
Summary

Chapter 13: Deploying Detectron2 Models into Browsers and Mobile Environments

Technical requirements
Deploying Detectron2 models using ONNX
Introduction to ONNX
Exporting a PyTorch model to ONNX
Loading an ONNX model to the browser
Exporting a custom Detectron2 model to ONNX
Developing mobile computer vision apps with D2Go
Introduction to D2Go
Using existing D2Go models
Training custom D2Go models
Model quantization
Summary

Index