DEV Community

PythicCoder for Microsoft Azure

Posted on • Originally published at towardsdatascience.com on

Attendance Estimation with Azure ML

Image from Pexels https://www.pexels.com/photo/people-on-stadium-event-1916816/

TLDR; This post provides an E2E Jupyter notebook for training crowd counting models with C-3-Framework and AzureML SDK for Python

What is Audience Estimation

Often as AI Cloud Developer Advocate I find myself talking in front of various audiences. Now that I have some time to work on some new demos while working from home I’ve been thinking of how to better understand the reach of the audience I talk too for when life resumes to normal.

Often I estimate the reach of my of talks based on registrations or by eyeballing but what if there was a better way. As an AI engineer I was inspired by the work done by the Microsoft CAT team on crowd counting. I couldn’t find any tutorials on how to train these kinds of models at scale on the cloud and decided to write my own and document the process for my readers.

Code for the post can be found below

aribornstein/AudienceEstimationAuzreML

If you are new to Azure you can get started a free subscription using the link below.

Create your Azure free account today | Microsoft Azure

Detection vs Dense Approaches

Before we get started we should try to understand the differences between the top two audience estimation approaches.

Pictured Dense Model on Left, Pose Detection Model on Right. Image from https://github.com/microsoft/computervision-recipes/tree/master/contrib/crowd_counting

Detection Based Approaches , such as person detection, semantic segmentation, and pose estimation, work best on small crowds but have trouble scaling to estimating the size of larger audiences of the dozens or more people.

Results of detection post and segmention from the pynino library https://github.com/hampen2929/pyvino

Dense Approaches try to learn a feature mapping between the original image and a density map of generated from placing a keypoint on all the people in the image. These models work best for estimating the size of larger audiences.

An example of Dense Map and the estimated output returned from Density Approximation Model

One of the most popular Dense models for is the Multi Column CNN (MCNN) Model due to it’s relatively quick evaluation time.

Running a Pretrained Dense Approximator Model

There is extensive documentation on how to train your own and use pre-trained detection based models in the cloud as well as some great out of the box cloud services.

In this post we will demonstrate how to run and train your own MCNN Dense Approximate Model with the AzureML SDK and the C-3-Framework.

The C-3 framework developed by Junyu Gao provides provide pre-processing code for six common mainstream crowd counting data sets and multiple model configurations of MCNN implemented in PyTorch.

gjy3035/C-3-Framework

In his GitHub Repo, Gao provides links to the processed datasets and pre-trained models he doesn’t provide an end to end example on one document, however so I took the liberty to write one in Jupyter notebooks myself that shows how to install the C3-Framework and run a pre-trained model.

aribornstein/AudienceEstimationAzureML

Training your own Dense Approximation Model at Scale with Azure ML

The Azure Machine Learning Service provides several ways to train machine learning models, from code first solutions using the SDKto low code solutions such as AutoML and the Visual Designer.

There are 8 simple steps for training a model with the AzureML SDK

The first 3 steps pertain to setting up your training infrastructure from choosing your compute to loading your data.

The remaining five steps relate to setting up the environment to run and experiment with different training scripts and manage the resulting model.

In the notebook below you will see an example of each of these 8 steps end to end with to train your own Audience Estimation models at scale.

aribornstein/AudienceEstimationAzureML

Once you run the notebook be sure to check out my 9tips for production machine learning and try playing around with code. I’ve left a couple of challenges for you to try at the bottom of the notebook.

9 Advanced Tips for Production Machine Learning

Additionally, I’ve included some other great resources on Crowd Counting below.

Additional Resources

Next Steps

Here are some additional resources to help with your computer vision journey on Azure.

About the Author

Aaron (Ari) Bornstein is an AI researcher with a passion for history, engaging with new technologies and computational medicine. As an Open Source Engineer at Microsoft’s Cloud Developer Advocacy team, he collaborates with Israeli Hi-Tech Community, to solve real world problems with game changing technologies that are then documented, open sourced, and shared with the rest of the world.


Top comments (0)