UX Collective

We believe designers are thinkers as much as they are makers. https://linktr.ee/uxc

Follow publication

Member-only story

Identifying people in photos using Python and Neural Networks

Daniel Ellis Research
UX Collective
Published in
4 min readOct 8, 2022
Person matching AI example.
Source: Program output of image https://unsplash.com/photos/IBaVuZsJJTo

About The Series

This article is part of a 2-piece set discussing the automated filtering of photographs.

  1. Identifying People in Photos using Python and Neural Networks
  2. Neural Image Assessment: Sorting photographs by Aesthetic and Technical Quality

Background

Many situations call that we identify photographs containing people within them. This could be from a security standpoint (we need to check if we have permission to publish photographs with people faces), or automation standpoint — e.g. if trying to filter photographs from a sports event or competition.

What is Detectron2?

Facebook AI Research’s collection of state-of-the-art object detection algorithm is called Detectron. This is based on the Mask R-CNN benchmark and is written in Python and PyTorch. It supports bounding box detection, densepose detection, instance segmentation, keypoint detection, and other computer vision tools.

Examples of its usage and research papers are located here.

Installation

Unfortunately, installation is limited to Unix operating systems. Although if you have installed the Linux subsystem on Windows, this should not be a problem.

conda install -c conda-forge detectron2;
pip install -U iopath==0.1.4 omegaconf opencv-python;

Setting Up the Script

To make use of detectron we begin by creating a python script made up from the following:

Imports

As usual, we start by importing the relevant libraries.

import detectron2,cv2
from detectron2 import model_zoo
from detectron2.engine import DefaultPredictor
from detectron2.config import get_cfg
from detectron2.utils.visualizer import Visualizer
from detectron2.data import MetadataCatalog, DatasetCatalog

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Written by Daniel Ellis Research

Research Software Engineer specialising in High-Performance Computing and Data Visualisation. — PhD in Atmospheric Chemistry and Masters in Theoretical Physics.

Write a response