<jupyter_start><jupyter_text>Intro In this notebook we are going to apply each model to the test images to compute the statistics we are going to use to compare the models.   Defining the parameters Most important part: define where to find the models to test as well as the data to test on._Note:_ The paths here are relative to where this notebook is located.Right now, it is located in the following folder: **root/notebooks/**<jupyter_code>path_model = '../models/defaults/default_SEM_model_v1/'
path_testing_data = '../data/baseline_validation/'<jupyter_output><empty_output><jupyter_text>Define here the parameters of the segmentation that we are going to use when calling the segmentation itself.<jupyter_code>overlap_value = 25<jupyter_output><empty_output><jupyter_text>Define here the resolution we are going to resample to when making the predictions. This depends on the type of the image, and should be the same float number as the one that was used for training.<jupyter_code>resampled_resolution = 0.1<jupyter_output><empty_output><jupyter_text>Applying the segmentations Our goal is to segment every validation or testing image. We don't want to generate the segmentation images but just return the predictions and the probabilties so that we can compute the statistics of the model on each testing image.<jupyter_code>sg.metrics_single_wrapper(path_model, path_testing_data, resampled_resolution, overlap_value=overlap_value)<jupyter_output><empty_output><jupyter_text>Converting the json file into an Excel file Use GDrive<jupyter_code>import pandas as pd, os, json
import matplotlib.pyplot as plt
from functools import partial
from AxonDeepSeg.testing.statistics_generation import metrics<jupyter_output><empty_output><jupyter_text>Displaying some metrics<jupyter_code>#model_list = [os.path.join('../test_models',e) for e in os.listdir('../test_models') if os.path.isdir(os.path.join('../test_models/', e))]
model_list = ["../models/defaults/default_SEM_model_v1/"]
met = metrics()
met.add_models(model_list)
#met.add_models([os.path.join('../models','baseline-SEM256new-9438/')])
met.load_models()
met.filtered_stats
met.filter_(list_acquisitions=['SEM'], write_mode=False, name_file='onSEM-5185.csv')
met.aggregate([np.min, np.mean, np.max], write_mode=True, name_file='onSEM-5185.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09195893926432848, 'fraction_numerical': 0.008982035928143712, 'mean_word_length': 6.694078947368421, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '417146', 'license': 'MIT', 'n_tokens_mistral': 737, 'n_tokens_neox': 703, 'n_words': 225, 'path': 'notebooks/statistics_generation.ipynb', 'repo_name': 'sagoyal2/edit_axondeepseg', 'size': '2338'}