Skip to content

Commit

Permalink
Merge branch 'johko:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
seshupavan authored Feb 13, 2024
2 parents c655bc3 + fe54721 commit 3928ddf
Show file tree
Hide file tree
Showing 9 changed files with 2,965 additions and 0 deletions.
47 changes: 47 additions & 0 deletions chapters/en/Unit 6 - Basic CV Tasks/object_detection.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Object Detection

In this chapter, we'll explore the fascinating world of object detection—a vital task in modern computer vision systems. We will demystify essential concepts, discuss popular methods, examine applications, and discuss evaluation metrics. By the end, you'll have a solid foundation and be ready to venture further into advanced topics.

![Image displaying the bounding boxes around multiple objects in the frame along with the confidence score of their classification](https://huggingface.co/datasets/hf-vision/course-assets/resolve/main/Object_Detection.png)
## Object Detection Overview

### Introduction

Object detection is the task of identifying and locating specific objects within digital images or video frames. It has far-reaching implications across diverse sectors, including self-driving cars, facial recognition systems, and medical diagnosis tools.

### Classification vs Localization

Classification distinguishes objects based on unique attributes, while localization determines an object's location within an image. Object detection combines both approaches, locating entities and assigning corresponding class labels. Imagine recognizing different fruit types and pinpointing their exact locations in a single image. That's object detection at play!

## Use Cases

Object detection impacts numerous industries, offering valuable insights and automation opportunities. Representative examples include autonomous vehicles navigating roads, surveillance systems covering vast public spaces, healthcare imaging systems detecting diseases, manufacturing plants maintaining output consistency, and augmented reality enriching user experiences.

Here is an example of object detection using transformers:
```python
from transformers import pipeline
from PIL import Image
pipe = pipeline('object-detection', model="facebook/detr-resnet-50")

image = Image.open("path/to/your/image.jpg").convert("RGB")

bounding_boxes = pipe(image)
```

## How to Evaluate an Object Detection Model?
You have now seen how to use an object detection model, but how can you evaluate it? As demonstrated in the previous section, object detection is primarily a supervised learning task. This means that the dataset is composed of images and their corresponding bounding boxes, which serve as the ground truth. A few metrics can be used to evaluate your model. The most common ones are:

- **The Intersection over Union (IoU) or Jaccard index** measures the overlap between predicted and reference labels as a percentage ranging from 0% to 100%. Higher IoU percentages indicate better alignments, i.e., improved accuracy. Useful when assessing tracker performance under changing conditions, e.g., following wild animals during migration.

- **Mean Average Precision (mAP)** estimates object detection efficiency using both precision (correct prediction ratio) and recall (true positive identification ability). Calculated across varying IoU thresholds, mAP functions as a holistic assessment tool for object detection algorithms. Helpful for determining the model's performance in localization and detection in challenging conditions like finding irregular surface defects that vary in size and shape in a manufactured part.

## Conclusion and Future Work

Understanding object detection lays the groundwork for mastering advanced computer vision techniques, enabling the construction of powerful and accurate solutions addressing rigorous needs. Some future research areas include developing lightweight object detection models which are fast and easily deployable. Exploration in the field of object detection in 3D space, e.g., for augmented reality applications, is another avenue to explore.

## References and Additional Resources

- [Hugging Face Object Detection Guide](https://huggingface.co/docs/transformers/tasks/object_detection)
- [Object Detection in 20 Years: A Survey](https://arxiv.org/abs/1905.05055)
- [Papers with Code - Real-Time Object Detection](https://paperswithcode.com/task/real-time-object-detection)
- [Papers with Code - Object Detection](https://paperswithcode.com/task/object-detection)
51 changes: 51 additions & 0 deletions chapters/en/Unit 9 - Model Optimization/tools_and_frameworks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ The Tensorflow Model Optimization Toolkit is available as a pip package, `tensor
pip install -U tensorflow-model-optimization
```

### Hands-on guide

For a hands-on guide on how to use the Tensorflow Model Optimization Toolkit, refer this [notebook](https://colab.research.google.com/drive/1t1Tq6i0JZbOwloyhkSjg8uTTVX9iUkgj#scrollTo=D_MCHp6cwCFb)
## Pytorch Quantization

### Overview
Expand All @@ -35,6 +38,9 @@ Pytorch quantization is available as API in the pytorch package. To use it simpl
pip install torch
import torch.quantization
```
## Hands-on guide

For a hands-on guide on how to use the Pytorch Quantization, refer this [notebook](https://colab.research.google.com/drive/1toyS6IUsFvjuSK71oeLZZ51mm8hVnlZv

## ONNX Runtime

Expand Down Expand Up @@ -64,6 +70,10 @@ For GPU version, run the following command:
pip install onnxruntime-gpu
```

### Hands-on guide

For a hands-on guide on how to use the ONNX Runtime, refer this [notebook](https://colab.research.google.com/drive/1A-qYPX52V2q-7fXHaLeNRJqPUk3a4Qkd)

## TensorRT

### Overview
Expand All @@ -80,6 +90,10 @@ pip install tensorrt
```
for other installation methods, see [here](https://docs.nvidia.com/deeplearning/tensorrt/quick-start-guide/index.html#install)

### Hands-on guide

For a hands-on guide on how to use the TensorRT, refer this [notebook](https://colab.research.google.com/drive/1b8ueEEwgRc9fGqky1f6ZPx5A2ak82FE1)

## OpenVINO

### Overview
Expand All @@ -100,6 +114,40 @@ pip install openvino

For other installation methods, see [here](https://docs.openvino.ai/2023.2/openvino_docs_install_guides_overview.html?VERSION=v_2023_2_0&OP_SYSTEM=LINUX&DISTRIBUTION=ARCHIVE)

### Hands-on guide

For a hands-on guide on how to use the OpenVINO, refer this [notebook](https://colab.research.google.com/drive/1FWD0CloFt6gIEd0WBSMBDDKzA7YUE8Wz)

## Optimum

### Overview

Optimum serves as an extension of [Transformers](https://huggingface.co/docs/transformers), offering a suite of tools designed for optimizing performance in training and
running models on specific hardware, ensuring maximum efficiency. In the rapidly evolving AI landscape, specialized hardware and unique optimizations continue to emerge regularly.
Optimum empowers developers to seamlessly leverage these diverse platforms, maintaining the ease of use inherent in Transformers.
Platforms suppoerted by optimum as of now are:
1. [Habana](https://huggingface.co/docs/optimum/habana/index)
2. [Intel](https://huggingface.co/docs/optimum/intel/index)
3. [Nvidia](https://github.com/huggingface/optimum-nvidia)
4. [AWS Trainium and Inferentia](https://huggingface.co/docs/optimum-neuron/index)
5. [AMD](https://huggingface.co/docs/optimum/amd/index)
8. [FuriosaAI](https://huggingface.co/docs/optimum/furiosa/index)
9. [ONNX Runtime](https://huggingface.co/docs/optimum/onnxruntime/overview)
10. [BetterTransformer](https://huggingface.co/docs/optimum/bettertransformer/overview)

### Setup guide

Optimum is available as a pip package, `optimum`. To install the package, run the following command:
```
pip install optimum
```

For installation of accelerator-specific features, see [here](https://huggingface.co/docs/optimum/installation)

### Hands-on guide

For a hands-on guide on how to use Optimum for quantization, refer this [notebook](https://colab.research.google.com/drive/1tz4eHqSZzGlXXS3oBUc2NRbuRCn2HjdN)

## EdgeTPU

### Overview
Expand All @@ -112,3 +160,6 @@ The benefits of using EdgeTPU includes:

For more details on EdgeTPU, see [here](https://cloud.google.com/edge-tpu)

For guide on how to setup and use EdgeTPU, refer this [notebook](https://colab.research.google.com/drive/1aMEZE2sI9aMLLBVJNSS37ltMwmtEbMKl)


Loading

0 comments on commit 3928ddf

Please sign in to comment.