vehicle-classification aggregates labeled vehicle images and classifies vehicle images on granularity of make, model, and generation. vehicle-classification leverages Grand Theft Auto V (GTA V) for labeled vehicle image aggregation (data set collection) and PyTorch to build a convolutional neural network (CNN) architecture to perform vehicle image classification on the granularity of make, model, and generation (e.g. '1992 Mercedes-Benz 500E', '2016 Audi Q7', '2016 Dodge Ram Rebel').
The following are examples of images classified by the classifier.
Windows 10 is required for data set collection. The software used for data set collection is as follows:
| Software/File | Version | Link |
|---|---|---|
| Grand Theft Auto V | 1.0.2060.1 | Epic Games |
| OpenIV | 4.0 | OpenIV |
| Script Hook V | 1.0.2060.1 | AB Software Development |
| Community Script Hook V .NET | 3.0.4 | GTA5-Mods |
| Gameconfig for Limitless Vehicles | 21.0 | GTA5-Mods |
| Heap Limit Adjuster | 1.0.0 | GTA5-Mods |
| Packfile Limit Adjuster | 1.1 | GTA5-Mods |
| NativeUI | 1.9.1 | GTAForums |
| GTA 5 Replace Carpack | 1.1 | Google Drive |
After the necessary applications and files have been installed and obtained respectively, use the following steps to prepare for data collection:
- Extract the ZIP archives for
Community Script Hook V .NET,Gameconfig for Limitless Vehicles,Heap Limit Adjuster,Packfile Limit Adjuster, andNativeUI. - Create
modsandscriptsdirectories in the GTA V game root directory (GTAV). - Launch
OpenIV, selectGTAV -> Windows, and locate the GTA V game root directory (GTAV) to specify installation location. - Click the
Edit modebutton to enter edit mode and selectYesto continue. Note that theEdit modebutton will be highlighted in blue whenOpenIVis in edit mode. - Click the
ASI Managerbutton to install ASI Loader and the OpenIV.ASI plugin for GTA V. - Click
Installfor ASI Loader and OpenIV.ASI. - From a
File Explorerwindow, dragGTA 5 Replace Carpack v.1.1.oivonto theOpenIVwindow. - Click the
Install*button inOpenIV. - Select
"mods" folderas the installation location. - Click the
Install* Confirm Installationbutton to confirm installation. - When
Installation succeededis displayed, clickClose. - Navigate to
GTA V/update/update.rpfinOpenIV, selectShow in "mods" folder, and navigate tocommon/data. - From a
File Explorerwindow, drag395267-GTAV Config v21.0\Gta Config v21 for v 1.0.2060\1,5x traffic\gameconfig.xmltoOpenIV. - Between
File Explorerwindows, drag3ef57d-GTAV.HeapAdjuster\GTAV.HeapAdjuster.asito the GTA V game root directory (GTAV), replacing if prompted. - Between
File Explorerwindows, dragNativeUI.dllto theGTAV\scriptsdirectory, replacing if prompted. - Between
File Explorerwindows, dragc901a6-PackfileLimitAdjuster\PackfileLimitAdjuster.asiandc901a6-PackfileLimitAdjuster\PackfileLimitAdjuster.inito the GTA V game root directory (GTAV), replacing if prompted. - Between
File Explorerwindows, dragScriptHookV_1.0.2060.1\bin\dinput8.dllandScriptHookV_1.0.2060.1\bin\ScriptHookV.dllto the GTA V game root directory (GTAV), replacing if prompted. - Between
File Explorerwindows, dragScriptHookVDotNet\ScriptHookVDotNet.asi,ScriptHookVDotNet\ScriptHookVDotNet2.dll, andScriptHookVDotNet\ScriptHookVDotNet3.dllto the GTA V game root directory (GTAV), replacing if prompted.
If you wish to build the GTAVehicleClassification.dll from source, the files DeveloperConsole.dll and VehicleLabeler.cs can be used to build GTAVehicleClassification.dll with Microsoft Visual Studio. VehicleLabeler.cs can be found in the vehicle-classification\data_collection directory. DeveloperConsole.dll and a pre-built GTAVehicleClassification.dll can be found in the vehicle-classification\data_collection\dlls directory.
To begin data collection, use the following steps:
- Copy
DeveloperConsole.dllandGTAVehicleClassification.dllto theGTAV\scriptsdirectory. - Create the directories
GTAV\scripts\imagesandGTAV\scripts\debug_images. - Launch the Grand Theft Auto V game.
Data collection will begin, storing images and image metadata to the GTAV\scripts\images directory.
To organize the collected labeled data into directories such that each directory is named with an identifier for the vehicle whose images it holds, use the following steps:
- Copy the
GTA\scripts\imagesdirectory to thevehicle-classificationdirectory. - Create the directory
vehicle-classification\processed_images. - Navigate to
vehicle-classification\processing. - Run
python process.py. (OpenCV is required to execute this script.)
Directories (one for each unique vehicle for which there were images collected) should be created in the vehicle-classification\processed_images directory.
Navigate to the vehicle-classification directory and setup a new conda environment using the following commands.
conda create -n vc python=3.8.5 -y
conda activate vc
conda install ipykernel -y
ipython kernel install --user --name=vc
Install the dependencies using the following command.
pip install -r requirements.txt
To train and test the classifier, run the cells of the Jupyter notebook classifier.ipynb, using jupyter lab, ensuring the vc kernel is selected.
Example training data is available in the training_data.npy file.
The accuracy of the classifier on GTA V vehicle images is around 70%. The following is a loss vs. epoch plot for the classifier's training stage:
- Rishi Masand








