Testing YOLOv3 CSGO Keras object detection

This is my last tutorial with object detection in CS:GO, check out what results I got with the custom YOLO v3 object detection model in this unusual aimbot

Welcome to another YOLO v3 custom object detection tutorial. I used a trained model to write a custom aimbot script. This part will give you all the details of how I trained the model to detect CS:GO enemies. First, if you want to test it by yourself, you can find code on GitHub. Alternatively, clone the whole directory with:

git clone https://github.com/pythonlessons/YOLOv3-object-detection-tutorial.git

This repository has 2 folders YOLOv3-CSGO-detection and YOLOv3-custom-training; this tutorial is about the first directory. So move to it.

The first thing you should do is go to the logs folder and unzip trained_weights_final.7z it to trained_weights_final.h5 to the same location. This is our trained YOLO v3 detection model.

Now run the realtime_detect.py script and make sure that your model_path, anchors_path, and classes_path are in the right location. Install all necessary libraries if you don't have a few of them.

Note that you must run realtime_detect.py as administrator, the same way I was doing in the video tutorial. Otherwise, moving targets and shooting will not work. You should open CMD as administrator, locate to YOLOv3-CSGO-detection folder and run python. realtime_detect.py.

Aimbot performance:

First of all, I was inspired to do this tutorial because I was not satisfied with the results from my past tutorial, where I couldn't get stable FPS in aimbot. At that time, one of my solutions was to explore and train the YOLO model, and finally, I did that! So, as a result, the maximum I can get is 22-24 FPS when not recording the above video tutorial:

I believe that there are many ways to improve this aimbot, but I decided not to invest more time in this. So there are few issues to fix:

  1. Need larger training database, because it sometimes detects wrong or does not detect heads at all;
  2. Right now, I wrote in code that the bot targets and shoots one time per detection. It means if I receive 20 FPS, it tries to move the mouse to target 20 times per second, and if we are targeting at the head, shoot it at the same rate.
  3. The bot constantly changes targets when we detect more than one object (heads, in my example). It would be nice to implement object tracking or check if it's the same object.

YOLO v3 aimbot training:

For training, I used the same dataset as last time. These images you can find on this GitHub link. To convert XML files in the right format to train the YOLO model, I wrote a script voc_to_YOLOv3_NO_CLASSES.py. This script doesn't require you to create a classes file or something like that. At the first loop, it collects all classes used in XML files. And on the second loop, it creates 2 files that are used for training, and these files are saved in the model_data folder. Then just run train.py according to my previous tutorial, where I explained how to train a custom YOLO v3 model.

I must mention that I wrote another cool script called collect_XLM_images.py. We can run this script uncommenting 2 lines in my realtime_detect.py code:

#if len(ObjectsList) > 0:
#    CreateXMLfile(img_clean, ObjectsList)

So this script creates an XML file with object coordinates received in real-time detection. This way, we can collect more training data; we need to play around with laggy CS:GO while running real-time detection. After we collect these images, we need to check them all. In this way, we can fix bad detection or detected rectangle size and so on. I just found that in this way, it's much easier to generate more training data.


This was my last tutorial with object detection while creating an aimbot for CS:GO. Maybe in the future, I will do something similar; we'll see, time will show. But for now, I will invest time in other areas.