YOLO

Author

Sparkgeo

First we need to build the correct environment for our YOLO model.

The best way to run the notebooks and Python applications provided is to create a virtual environment with

mkvirtualenv -p python3 worldbank

Inside the virtual environment, run

pip install -r requirements.txt

This should install all of the required Python modules into the virtual environment.

Training Data

Training data can be downloaded from their respective sources. Sparkgeo recommends xView for the object classes relevant to World Bank. Which you can find here


Darknet

With Darknet, you can train your own neural networks to recognize patterns and make predictions based on data. The framework is written in the C programming language, which means it is very fast and efficient. This makes it a popular choice for people who need to train neural networks on large datasets or in real-time applications.

One of the most well-known uses of Darknet is in the development of YOLO (You Only Look Once), an object detection algorithm that can identify multiple objects in an image with a single pass. YOLO has been used in a variety of applications, from self-driving cars to surveillance systems.

YOLO

YOLO (You Only Look Once) is a popular object detection algorithm that can detect multiple objects in an image with high accuracy and speed. It is widely used in applications such as autonomous vehicles, security systems, and augmented reality.

Usage

Tip

Make sure you’re in the right directory or cd .. from the /notebooks directory.

For the provided example applications, activate the virtual environment and then run one in this fashion:

python src/count_cars.py --detection-file data/processed/test_cars.gpkg --intersect-file data/processed/beitbridge_road_mask_v2.gpkg --output-json cars.geojson

You should get a result:

Total area occupied in the input detection file: 117.73855453912131 square meters
Total area of the intersection file: 850158.9421823191 square meters
Total area of the objects in the intersections: 21.294459917308703 square meters
Number of vehicles inside the roads area: 1
Individual areas of the intersection
Class: car Confidence: 69.3 Area: 21.294459917308703 square meters

Alternatively

To compile Darknet yourself you can:

  • Download and install Darknet on your system. The Darknet website has a pre-built binary for Windows and instructions for building from source code on other platforms.

  • Acquire a dataset of images and annotations. There are many public datasets available, such as COCO or VOC, that contain images with object annotations. Alternatively, you can create your own dataset by annotating objects in images using tools such as LabelImg.

  • Convert the dataset into Darknet format. Darknet uses a specific format for image and annotation files, which can be converted using scripts provided with the framework or third-party tools.

  • Train the neural network using Darknet. This involves defining a configuration file that specifies the network architecture and training parameters, and running the darknet executable with the appropriate arguments to start training.

  • Evaluate the trained network on test data. This involves running the darknet executable with arguments that specify the test data and network weights, and examining the output to evaluate the performance of the network.

Use the trained network for object detection. This involves running the darknet executable with arguments that specify the image or video to process, and the trained network weights. The output will be a set of bounding boxes and class labels that identify the objects in the input image or video.