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
mods
andscripts
directories 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 mode
button to enter edit mode and selectYes
to continue. Note that theEdit mode
button will be highlighted in blue whenOpenIV
is in edit mode. - Click the
ASI Manager
button to install ASI Loader and the OpenIV.ASI plugin for GTA V. - Click
Install
for ASI Loader and OpenIV.ASI. - From a
File Explorer
window, dragGTA 5 Replace Carpack v.1.1.oiv
onto theOpenIV
window. - Click the
Install*
button inOpenIV
. - Select
"mods" folder
as the installation location. - Click the
Install* Confirm Installation
button to confirm installation. - When
Installation succeeded
is displayed, clickClose
. - Navigate to
GTA V/update/update.rpf
inOpenIV
, selectShow in "mods" folder
, and navigate tocommon/data
. - From a
File Explorer
window, drag395267-GTAV Config v21.0\Gta Config v21 for v 1.0.2060\1,5x traffic\gameconfig.xml
toOpenIV
. - Between
File Explorer
windows, drag3ef57d-GTAV.HeapAdjuster\GTAV.HeapAdjuster.asi
to the GTA V game root directory (GTAV
), replacing if prompted. - Between
File Explorer
windows, dragNativeUI.dll
to theGTAV\scripts
directory, replacing if prompted. - Between
File Explorer
windows, dragc901a6-PackfileLimitAdjuster\PackfileLimitAdjuster.asi
andc901a6-PackfileLimitAdjuster\PackfileLimitAdjuster.ini
to the GTA V game root directory (GTAV
), replacing if prompted. - Between
File Explorer
windows, dragScriptHookV_1.0.2060.1\bin\dinput8.dll
andScriptHookV_1.0.2060.1\bin\ScriptHookV.dll
to the GTA V game root directory (GTAV
), replacing if prompted. - Between
File Explorer
windows, dragScriptHookVDotNet\ScriptHookVDotNet.asi
,ScriptHookVDotNet\ScriptHookVDotNet2.dll
, andScriptHookVDotNet\ScriptHookVDotNet3.dll
to 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.dll
andGTAVehicleClassification.dll
to theGTAV\scripts
directory. - Create the directories
GTAV\scripts\images
andGTAV\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\images
directory to thevehicle-classification
directory. - 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