# Thundernet Thundernet is a semantic segmentation model that processes RGB input using convolutional networks to extract key features. ### USE OF THE REPOSITORY - TRAINING To execute the train file: python train_config.py You can change the parameters adding them as flags in the previous command or changing them directly in the Thundernet_config.py file The parameters that you can include (that are relevant for training) are: - **train_path (str)**: path to the train data (default: "C:/Users/user/Documents/pruned_training/training/") - **val_path (str)**: path to the val data (default: "C:/Users/user/Documents/pruned_training/val/") - **model_dir (str)**: path to save the trained model (default: "C:/Users/user/Documents/Thundernet/pruebas_modelos/" ) - **model_weights (str)**: NOT APPLICABLE FOR TRAINING path to the trained weights (default: "C:/Users/user/Documents/Thundernet/pruebas_modelos/32_ppm/BS4_lossBCE_weights_lr_0.00013713842558297858_reg-1.1743577101671763e-05-ep-13-val_loss0.11463435739278793-train_loss0.053004469722509384-val_iou0.8959722518920898-train_iou0.9606077075004578.hdf5") - **batch_size (int)**: batch size (default: 4) - **loss (str)**: type of loss to use (default: "BCE") - **classes (int)**: number of classes (default: 2). The original purpose of the code was to segment egocentric bodies, so two classes were involved (body and background) - **pretrained (bool)**: start from a pretrained model (default: False) - **pretrained_weights (str)**: path to the pretrained model (default: None) - **lr (float)**: learning rate (default: 1e-4) - **epochs (int)**: number of epochs (default: 15) - **resolution (str)**: resolution of input images (defualt: 640x480) - **kernel_regularizer (float)**: kernel regularizer (default: 2e-4) Note: there are more parameters in the file, but they are no use for training ### USE OF THE REPOSITORY - EVALUATION To execute the evaluation, you can execute: python inference_config.py You can change the parameters adding them as flags in the previous command or changing them directly in the Thundernet_config2.py file (that are relevant for evaluation) are: - **model_weights (str)**: NOT APPLICABLE FOR TRAINING path to the trained weights (default: "C:/Users/user/Documents/Thundernet/pruebas_modelos/32_ppm/BS4_lossBCE_weights_lr_0.00013713842558297858_reg-1.1743577101671763e-05-ep-13-val_loss0.11463435739278793-train_loss0.053004469722509384-val_iou0.8959722518920898-train_iou0.9606077075004578.hdf5") - **batch_size (int)**: batch size (default: 4) - **resolution (str)**: resolution of input images (defualt: 640x480) Note: there are more parameters in the file, but they are no use for evaluation In the inference_config.py file you can execute the main with a "show=True" to display some predictions. However, you will have to close the image after every prediction. ### DATA PREPARATION The data must be stored in a path with the following structure: - data + images (folder with RGB images in a .jpg format) -- example1.jpg + labels (folder with label images in a .png format) -- example1.png The name for the files should be the same for the image and it's corresponding label. ### OPTIMIZE HYPERPARAMETERS To find the best hyperparameters for training, you can execute the train_optuna.py file. This file will find the optimal values for batch_size, learning_rate and kernel_regularizer. The rest of the hyperparameters values will be obtained from the "thundernet_config.py" file. #### Compare models To compare if two models are the same (the weights are equal), the file "compare_models.py" can be executed. The path to the model's weights should be changed in the "weights_path1" and "weights_path2" variables.