- Angelegt von Bigge, Julian, zuletzt geändert am 27. Mai 2021
Sie zeigen eine alte Version dieser Seite an. Zeigen Sie die aktuelle Version an.
Unterschiede anzeigen Seitenhistorie anzeigen
« Vorherige Version anzeigen Version 5 Nächste Version anzeigen »
The crucial goal of object detection on images is, to classify and find (multiple) occurrences of different object categories. There exists a wide variety of neural network architectures tackling this task.
These networks are as a general rule compared based on well-known datasets such as COCO with regards to their mAP (mean average precision) score.
Some popular choices at the time of writing this are e.g.
- Faster R-CNN
- SSD-MobileNet
- YOLOv4
Especially the YOLO architectures have proven to be a quite uniquely great balance between detection/classification accuracy and performance, even on lower-end devices such as mobiles.
In this article, we will have a look at how YOLO in combination mit PyTorch can be used on Palma to train a new YOLO-model which can be used for object detection on your own images. After the training procedure you can download your model and, for example, start the inference on your own device. Further, we will use the modified YOLOv4-CSP architecture, which is currently the best performing YOLO.
Preparation
Install requirements
Before we can start training, we will first have to install some requirements for the PyTorch implementation of YOLOv4-CSP. Using Python, most of them can be installed by using Python's package manager pip
. As we want to use a GPU to accelerate the training process, we use Palma's gputitanrtx
queue. For installation of the requirements it is recommended to queue an interactive job on one of the gputitanrtx
hosts, so that any compiling involved is done on the correct hardware architecture.
First thing to do on the GPU node is to load the required modules to our shell session, e.g.
module load palma/2019b module load fosscuda module load OpenCV module load PyTorch module load torchvision
Now we can start to install our requirements. You can download this requirements.txt which should include all necessary packages and then upload it to your home directory on Palma an install it via
pip3 install --user -r requirements.txt
One last required package has to be installed manually: mish-cuda, which provides a CUDA accelerated implementation of the MISH activation function. To install it you can use
git clone https://github.com/JunnYu/mish-cuda pip3 install --user ./mish-cuda
Finally, as a last step, we can clone the PyTorch implementation of YOLO itself with
git clone --single-branch --branch yolov4-csp https://github.com/WongKinYiu/ScaledYOLOv4
You should now have a folder called ScaledYOLOv4
in which you can find the necessary Python scripts for training and inference. You can now exit you shell session on the GPU host.
Configure YOLO
Next thing to do is to fine-configure YOLO for your new custom model. First, we need to tell YOLO about the names of your classes.
vim ScaledYOLOv4/data/dataset.names
and put each class label in its own line. You can also have a look at ScaledYolov4/data/coco.names
for the right format.
In a similar way, you will also have to create a new configuration file with the path ScaledYolov4/data/dataset.yaml
and the following contents:
train: data/train.txt val: data/test.txt nc: <NUMBER OF CLASS LABELS> names: [<COMMA-SEPARATED LIST OF CLASS LABELS WITH THE SAME ORDER THAN USED IN dataset.names>]
Again, you can have a look at the file ScaledYolov4/data/coco.yaml
as an example.
As a last step, the exact model structure must be adapted to your dataset. Pay close attention to the following steps. They are easily mixed up which can result in significant problems when training the model. First, copy the default configuration for COCO:
cp ScaledYolov4/models/yolov4-csp.cfg ScaledYolov4/models/yolov4-csp-custom.cfg
Then open the new file in the editor of your choice (e.g. vim
) and proceed with the following sets of changes for best performance:
- hange line batch to
batch=64
- change line subdivisions to
subdivisions=16
- change line max_batches to (
classes*2000
, but not less than number of training images and not less than6000
), f.e.max_batches=6000
if you train for 3 classes
Upload your training data
Next thing to do, now that we have setup the software environment and configured YOLO is to upload our training data to Palma to make it available for the training procedure. The training data has to be in an understandable format for YOLO
Homepage | https://pjreddie.com/darknet/yolo/ |
Publications | |
Articles | |
YOLOv4 Implementations (Python) |
- Keine Stichwörter