Training and inference of image recognition model for Cats and Dogs classification task with kotlinDL
To use KotlinDL in your project, add the following dependency to your build.gradle
file:
repositories {
mavenCentral()
}
dependencies {
implementation ("org.jetbrains.kotlinx:kotlin-deeplearning-api:[KOTLINDL-VERSION]")
}
For the reference use build.gradle.kts
from this repository
VGG11
model was trained for 10 epochs on CPU.
It obtained accuracy on test set equals 0.84.
And 1.0 accuracy on special images.
train.kt
script is used for training the model and evaluation on test data.
inference.kt
script is used for inference of the pretrained model and evaluation on test data and special images.
Pre-trained model for inference can be downloaded here. The archive should be unpacked to the root of the project.
Model was trained with standard dataset dogsCatsDataset
from kotlinDL framework.
The model was tested with additional data for checking the generalization abilities:
Cat (looks like dog) | Dog (with confusing cat mask pattern) |
---|---|
![]() |
![]() |
Any other data can be added to special images directory (according to class file structure) and test the model.
VGG11 architecture was used for classification task. Realization was adopted from examples in kotlinDL repository.
Model can be replaced with LeNet
architecture. Both architectures are presented here.