VisualAI is an mini artificial intelligence project written in Java and Angular that's made for training on custom image data and then object recognition within images. It's flexible and easy to use.
VisualAI consists of 3 projects:
- Model trainer (
/src/model
directory ) - Mini neural network written in Java controlled completely using a singleconf.json
file ( see/src/model/conf.example.json
for reference ) - Model API (
/src/api
directory ) - Mini API written using Spring Boot consisting of 2 routes, one (GET
@/list
) written for listing all requests and another one (POST
@/predict/{model_id}
) written for fetching probabilities estimated by neural network for each specific label - Model Web (
/src/web
directory ) - Mini web application written in Angular made for listing these models and general usage easier
Neural network in VisualAI is as follows:
And is controlled by parameters provided in models conf.json
file which describes basic meta of the model, training parameters, labels and features.
Example below shows an cat/dog classifing model called animal-recognizer
. To start, we are first going to train the model using 5 images of dogs and 5 images of cats which we are going to label cat
and dog
. We will be training this for 10 epochs with default seed of 1, normalization resolution of 500x500 and learning rate a bit over the usual and average one, 0.005. Configuration file ( conf.json
) will look like this:
{
"name": "animal-recognizer",
"version": "v0.1",
"training_parameters": {
"resolution": [
500,
500
],
"learning_rate": 0.005,
"seed": 1,
"epochs": 10
},
"labels": [
{
"id": "dog",
"data": [
"../train_data/dog.1.jpg",
"../train_data/dog.2.jpg",
"../train_data/dog.3.jpg",
"../train_data/dog.4.jpg",
"../train_data/dog.5.jpg"
]
},
{
"id": "cat",
"data": [
"../train_data/cat.1.jpg",
"../train_data/cat.2.jpg",
"../train_data/cat.3.jpg",
"../train_data/cat.4.jpg",
"../train_data/cat.5.jpg"
]
}
]
}
Once we've done that, we can proceed by running train.cmd
in the terminal. After some time ( depending on machine ), we should see an simple output like this:
Then, we are free to run our API and web application. We are going to run API by going to /src/api
directory and running mvnw spring-boot:run
. Then, we can go to /src/web
and run npm start
. We should see the following: