Object detection in games – YOLO + Rollercoin
Today we will be identifying objects in screenshots of the Rollercoin game using the YOLO model load. Since we need to identify non-people, we will start by training our own model based on the underlying data. So, the first action is to download one of the latest YOLO models.
Step 1
Download YOLO model:
https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt
Next record a good quality video of the required Rollercoin game, I will be using a game called ‘Botcoinclick’.
Task #1 is to put all the data in one folder, such as:
- YOLO model – download and save in folder,
- frames from the video game – get frames from video by running the script.
Now we do the following: use the service https://www.makesense.ai/ to mark up and manually identify coins or other objects . In our case there are 2 layers or classes – coin and bomb. You can, of course, use other solutions for this purpose, but for me the optimal one turned out to be this one.
After selecting the desired objects in the screenshots and providing labels, export the annotations in a format for YOLO. Extract the archive into the folder with all the other files, namely into the ‘labels’ subfolder. Preliminary in the ‘images’ subfolder we put screenshots, on which we taught annotations.
To properly test and create a model to identify objects in the images, you must first prepare all the folders, for this action will use another script that will put all the necessary data into folders.
Now the mandatory action is to customize the ‘data.yaml’ configuration file located inside the main folder. In this file we specify exactly how the model should define and which classes, for example:
train: F:/PYTHON/BOTS/RollercoinBot-master/RollerCoin.v11i.yolov11/images
val: F:/PYTHON/BOTS/RollercoinBot-master/RollerCoin.v11i.yolov11/val
nc: 2
names: ['coin, bomb']
Oh, and don’t forget to create a new environment so the libraries don’t conflict with your other data – this is important!
C:/Users/YOURACCOUNT/AppData/Roaming/Ultralytics/settings.json
– here we check the correct path to the training folder of the model.
For example:
"datasets_dir": "F:\\PYTHON\\BOTS\\RollercoinBot-master\\RollerCoin.v11i.yolov11\\"
Now in terminal (with new environment) run model training:
yolo train model=F:\PYTHON\BOTS\RollercoinBot-master\RollerCoin.v11i.yolov11\yolo11n.pt data=F:\PYTHON\BOTS\RollercoinBot-master\RollercoinBot-master\RollerCoin.v11i.yolov11\data.yaml epochs=50 imgsz=640
After the model is trained, move it to the main folder or wherever you need it and specify the path to the model in the script.
Check if the customized model works correctly in the image or video.
Professional data parsing via ZennoPoster, Python, creating browser and keyboard automation scripts. SEO-promotion and website creation: from a business card site to a full-fledged portal.