Train a new model
Folder structure
To ensure a smooth runnig of all the functions during the process, the folder containing the images should be organised as the following structure. The images should have the format .jpg or .png, and the ground truth should have the .mat format. The .mat files can be generated based on images by using this Matlab script
The first step is then to load a list of the path to all your images using the dir_to_list function. This list will be used in a lot of the following steps.
from Crowd_counting.augmentation import dir_to_list
img_path = 'Project/images'
img_paths,GT_paths = dir_to_list(img_path)
Data augmentation
The Data augmentation Module permits to perform some data augmentation directly on the images and their ground truth. The different available modifications are detailed on the module’s documentation page.
Ground_truth generation
In order to train the models, it is first needed to create the ground_truth density maps in the .h5 format as in the following code.
from Crowd_counting.ground_truth import gt_gen
gt_gen(img_paths,Verbose = True)
Model training
The model is trainable directly in python.
from Crowd_counting.train import *
complete_train('Project/images')
The model can also be trained via the terminal by following the creators method
Model evaluation
The Model Module contain a function called evaluate that can be used to evaluate the MAE and MSE of the models.
from Crowd_counting.model import evaluate
MAE,MSE = evaluate(my_model,img_paths)