Commit bbf27d78 authored by Andrei-Claudiu Roibu's avatar Andrei-Claudiu Roibu 🖥
Browse files

completed function that finds the avg dice score

parent 76965ce7
......@@ -22,6 +22,8 @@ from BrainMapperUNet import BrainMapperUNet
import torch.utils.data as data
from solver import Solver
import os
from utils.data_logging_utils import LogWriter
import utils.data_evaluation_utils as evaluations
# Set the default floating point tensor type to FloatTensor
......@@ -177,13 +179,121 @@ def train(data_parameters, training_parameters, network_parameters, misc_paramet
print("Final Model Saved in: {}".format(model_output_path))
def evaluate_path():
pass
def evaluate_score(data_parameters, training_parameters, network_parameters, misc_parameters, evaluation_parameters):
"""Mapping Score Evaluator
This function evaluates a given trained model by calculating the it's dice score prediction.
Args:
data_parameters (dict): Dictionary containing relevant information for the datafiles.
data_parameters = {
'data_directory': 'path/to/directory'
'train_data_file': 'training_data'
'train_output_targets': 'training_targets'
'test_data_file': 'testing_data'
'test_target_file': 'testing_targets'
}
training_parameters(dict): Dictionary containing relevant hyperparameters for training the network.
training_parameters = {
'training_batch_size': 5
'test_batch_size: 5
'use_pre_trained': False
'pre_trained_path': 'pre_trained/path'
'experiment_name': 'experiment_name'
'learning_rate': 1e-4
'optimizer_beta': (0.9, 0.999)
'optimizer_epsilon': 1e-8
'optimizer_weigth_decay': 1e-5
'number_of_epochs': 10
'loss_log_period': 50
'learning_rate_scheduler_step_size': 3
'learning_rate_scheduler_gamma': 1e-1
'use_last_checkpoint': True
'final_model_output_file': 'path/to/model'
}
network_parameters (dict): Contains information relevant parameters
network_parameters= {
'kernel_heigth': 5
'kernel_width': 5
'kernel_classification': 1
'input_channels': 1
'output_channels': 64
'convolution_stride': 1
'dropout': 0.2
'pool_kernel_size': 2
'pool_stride': 2
'up_mode': 'upconv'
'number_of_classes': 1
}
def evaluate_network():
misc_parameters (dict): Dictionary of aditional hyperparameters
misc_parameters = {
'save_model_directory': 'directory_name'
'model_name': 'BrainMapper'
'logs_directory': 'log-directory'
'device': 1
'experiments_directory': 'experiments-directory'
}
evaluation_parameters (dict): Dictionary of parameters useful during evaluation.
evaluation_parameters = {
'trained_model_path': 'path/to/model'
'data_directory': 'path/to/data'
'targets_directory': 'path/to/targets'
'data_list': 'path/to/datalist.txt/
'orientation': 'coronal'
'saved_predictions_directory': 'directory-of-saved-predictions'
}
Returns:
None
Raises:
None
"""
logWriter = LogWriter(number_of_classes= network_parameters['number_of_classes'],
logs_directory= misc_parameters['logs_directory'],
experiment_name= training_parameters['experiment_name']
)
prediction_output_path = os.path.join(misc_parameters['experiments_directory'],
training_parameters['experiment_name'],
evaluation_parameters['saved_predictions_directory']
)
average_dice_score = evaluations.evaluate_dice_score(trained_model_path= evaluation_parameters['trained_model_path'],
number_of_classes= network_parameters['number_of_classes'],
data_directory= evaluation_parameters['data_directory'],
targets_directory= evaluation_parameters['targets_directory'],
data_list= evaluation_parameters['data_list'],
orientation= evaluation_parameters['orientation'],
prediction_output_path= prediction_output_path,
device= misc_parameters['device'],
logWriter= logWriter
)
logWriter.close()
def evaluate_mapping():
"""
Function which maps an entire volume
"""
# Need to load all the relevant parameters
# Assuming I perform the split on multiple axes, I need to load the different paths
# After loading the different paths, evaluate:
# 1) either on one path
# 2) on two+ paths
pass
def delete_files():
""" Function which clears contents (like experiments or logs)
"""
pass
if __name__ == '__main__':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment