Human Crowd Detection with public Webcam Part 4

Crowd and Capacity Monitoring - MONICA - Sound and security applications  for large, open-air events

How to Train YOLOv5 on Custom Objects?

This tutorial is based on the YOLOv5 repository with Google Collab.

This notebook shows training on your own custom objects with

Data Annotation Tools at Roboflow.

Steps Covered in this Tutorial

In this tutorial, we will walk through the steps required to train YOLOv5 on your custom objects. We use a public blood cell detection datasets, which is open source and free to use. You can also use this notebook on your own data.

To train our detector we take the following steps:

  1. Annotation the unlabeled data using Roboflow
  2. Install YOLOv5 dependencies
  3. Download custom YOLOv5 object detection data
  4. Write our YOLOv5 Training configuration
  5. Run YOLOv5 training
  6. Evaluate YOLOv5 performance
  7. Visualize YOLOv5 training data
  8. Run YOLOv5 inference on test images
  9. Export saved YOLOv5 weights for future inference

1- Annotation Data with Roboflow Annotation Platform:

Roboflow provides everything you need to turn images into information. We build all the tools necessary to start using computer vision, even if you’re not a machine learning expert (and to supercharge your pipeline if you are).

Steps:

  1. Adding Data

To get started, create an account using your email or GitHub account: https://app.roboflow.com

After reviewing and accepting the terms of servic­e, you’ll land on your project’s homepage,

Click “Create New Project” and then select dataset folder

Once you selected the human-dataset folder into Roboflow, the images and annotations are processed for you to see them
overlayed.

You will be asked to select a train/test split for your images; the default of 70% training, 20% validation,
and 10% testing is usually a safe bet.

2. Annotating Images:

One of the images in the sample dataset is not yet annotated.
You will use Roboflow Annotate to add a box around the unlabeled chess piece in the image.
Annotations are the “answer key” your computer vision model learns from.

3. Preprocessing and Augmentations:

After you’re done annotating, continue to generate a new version of your datasets. This creates a point-in-time snapshot
of your images processed in a particular way (think of it a bit like version control for data).

Note:

If you’ve worked with computer vision, you’ll note augmentations are typically performed at the time of training your models.
Augmenting before training has three notable advantages.

First, it improves model reproducibility, easing debugging and performance improvement. For example, your model might quietly perform better on images captured in brighter rooms. By having a copy of the darker augmentations, debugging with inference is far easier.

Second, augmenting first reduces your training time and cost. When training with GPUs, augmentations are CPU-constrained operations. Thus, your GPUs are kept waiting for CPU operations to finish augmentations, increasing your training time and costs. (Saving around 12% training costs in our tests!)

Third, instead of (re)writing your augmentation scripts (or model config files) for each different model you train, you can have a consistent set of augmentations and images to compare across models head-to-head.

4. Exporting Data from Roboflow for Training:

let’s use the “YOLOv5 PyTorch” export format. When you click “Export”, your dataset is zipped, and you are given
several options for using it.

Click the “your dataset” link to download your zipped export to your computer. It contains an export folder with your images
and annotations and a README describing the transformations you provided to your data

References:

  1. https://blog.roboflow.com/getting-started-with-roboflow/
Facebook
Twitter

Unlimited access to educational materials for subscribers

Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Tutor LMS website.
Hi, Welcome back!
Forgot?
Don't have an account?  Register Now