Reader small image

You're reading from  Active Machine Learning with Python

Product typeBook
Published inMar 2024
PublisherPackt
ISBN-139781835464946
Edition1st Edition
Right arrow
Author (1)
Margaux Masson-Forsythe
Margaux Masson-Forsythe
author image
Margaux Masson-Forsythe

Margaux Masson-Forsythe is a skilled machine learning engineer and advocate for advancements in surgical data science and climate AI. As the Director of Machine Learning at Surgical Data Science Collective, she builds computer vision models to detect surgical tools in videos and track procedural motions. Masson-Forsythe manages a multidisciplinary team and oversees model implementation, data pipelines, infrastructure, and product delivery. With a background in computer science and expertise in machine learning, computer vision, and geospatial analytics, she has worked on projects related to reforestation, deforestation monitoring, and crop yield prediction.
Read more about Margaux Masson-Forsythe

Right arrow

Applying Active Learning to Computer Vision

In this chapter, we will dive into using active learning techniques for computer vision tasks. Computer vision involves analyzing visual data such as images and videos to extract useful information. It relies heavily on machine learning models such as convolutional neural networks. However, these models require large labeled training sets, which can be expensive and time-consuming to obtain. Active ML provides a solution by interactively querying the user to label only the most informative examples. This chapter demonstrates how to implement uncertainty sampling for diverse computer vision tasks. By the end, you will have the tools to efficiently train computer vision models with optimized labeling effort. The active ML methods presented open up new possibilities for building robust vision systems with fewer data requirements.

By the end of this chapter, you will be able to do the following:

  • Implementing active ML for an image...

Technical requirements

In this chapter, you will need to install the Ultralytics, PyYAML, and Roboflow packages.

Ultralytics is a popular open source Python library for building high-performance computer vision and deep learning models. It provides implementations of state-of-the-art object detection and image segmentation models including YOLO that can be trained on custom datasets.

PyYAML is a Python library used for reading and writing YAML files. YAML is a human-readable data serialization format. PyYAML allows loading YAML data from files or strings into Python data types such as dictionaries and lists. It can also dump Python objects back into YAML strings.

Roboflow, as presented in earlier chapters, is a platform that helps with preparing and managing datasets for computer vision models. It provides tools to annotate images, create training/test splits, and export labeled datasets in formats that are usable by deep learning frameworks such as PyTorch. Roboflow also...

Implementing active ML for an image classification project

In this section, we will guide you through the implementation of active ML techniques for an image classification project. Image classification has various applications in computer vision, ranging from identifying products for an e-commerce website to detecting patterns of deforestation on geospatial tiles. However, creating accurate image classifiers requires extensive datasets of labeled images, which can be expensive and time-consuming to gather, as mentioned in Chapter 1, Introducing Active Machine Learning. Active ML offers a solution to this labeling bottleneck by interactively requesting the oracle to label only the most informative examples.

We will build an image classification model that will be capable of accurately classifying various images obtained from the CIFAR-10 dataset. This dataset is widely recognized in the field of computer vision and contains a diverse collection of 60,000 images, each belonging to...

Applying active ML to an object detection project

In this section, we will guide you through the implementation of active ML techniques for an object detection project. An object detection project refers to developing a computer vision model to detect and localize objects within images or videos. The dataset is a collection of images (video frames) containing examples of the objects you want to detect, among other things. The dataset needs to have labels in the form of bounding boxes around the objects. Popular datasets for this purpose include COCO (https://cocodataset.org/), PASCAL VOC (http://host.robots.ox.ac.uk/pascal/VOC/), and OpenImages (https://storage.googleapis.com/openimages/web/index.html). The model architecture uses a neural network designed for object detection such as Faster R-CNN, YOLO, and so on. This type of architecture can automatically identify and localize real-world objects within visual data. The end result is a model that can detect and draw boxes around...

Using active ML for a segmentation project

In this section, we will reuse what we did for the object detection task, but instead of using an object detection dataset, we will use an instance segmentation dataset with the segment task of yolov8.

Instance segmentation is a computer vision task that involves detecting and segmenting individual objects in an image at the pixel level. It combines elements of object detection, which localizes objects by drawing bounding boxes around them, and semantic segmentation, which classifies each pixel in the image according to the class it belongs to. Instance segmentation goes a step further – it assigns an instance label to each segmented object. The output is a set of masks, one per detected object instance, that indicate the exact pixels that belong to each object. Instance segmentation provides a more detailed delineation of objects compared to the bounding boxes produced in object detection. It segments objects at the pixel level...

Summary

In conclusion, this chapter has demonstrated how active ML can be applied to optimize the training of computer vision models. As we have seen, computer vision tasks such as image classification, object detection, and instance segmentation require large labeled datasets to train convolutional neural networks (CNNs). Manually collecting and labeling this much data is expensive and time-consuming.

Active ML provides a solution to this challenge by intelligently selecting the most informative examples to be labeled by a human oracle. Strategies such as uncertainty sampling query the model to find the data points it is least certain about. By labeling only these useful data points, we can train our models with significantly less data-labeling effort required.

In this chapter, we covered implementing active ML approach for diverse computer vision applications. By interactively querying the model and refining the training data, we can rapidly improve model performance at a fraction...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Active Machine Learning with Python
Published in: Mar 2024Publisher: PacktISBN-13: 9781835464946
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Margaux Masson-Forsythe

Margaux Masson-Forsythe is a skilled machine learning engineer and advocate for advancements in surgical data science and climate AI. As the Director of Machine Learning at Surgical Data Science Collective, she builds computer vision models to detect surgical tools in videos and track procedural motions. Masson-Forsythe manages a multidisciplinary team and oversees model implementation, data pipelines, infrastructure, and product delivery. With a background in computer science and expertise in machine learning, computer vision, and geospatial analytics, she has worked on projects related to reforestation, deforestation monitoring, and crop yield prediction.
Read more about Margaux Masson-Forsythe