def test_EVALUATION_crossValidation_splitRun(self): eval_path = os.path.join(self.tmp_dir.name, "evaluation") split_folds(self.sample_list, k_fold=3, evaluation_path=eval_path) self.assertTrue(os.path.exists(eval_path)) self.assertTrue(os.path.exists(os.path.join(eval_path, "fold_0"))) self.assertTrue(os.path.exists(os.path.join(eval_path, "fold_1"))) self.assertTrue(os.path.exists(os.path.join(eval_path, "fold_2"))) for fold in range(0, 3): run_fold(fold, self.model, epochs=1, iterations=None, evaluation_path=eval_path, draw_figures=False, callbacks=[], save_models=True) fold_dir =os.path.join(eval_path, "fold_0") self.assertTrue(os.path.exists(os.path.join(fold_dir, "history.tsv"))) self.assertTrue(os.path.exists(os.path.join(fold_dir, "sample_list.json"))) self.assertTrue(os.path.exists(os.path.join(fold_dir, "model.hdf5")))
# You should have received a copy of the GNU General Public License # # along with this program. If not, see <http://www.gnu.org/licenses/>. # #==============================================================================# #-----------------------------------------------------# # Library imports # #-----------------------------------------------------# import tensorflow as tf from miscnn.data_loading.interfaces import NIFTI_interface from miscnn import Data_IO from miscnn.evaluation.cross_validation import split_folds #-----------------------------------------------------# # Running Preprocessing # #-----------------------------------------------------# for i in range(2, 5): # Initialize Data IO Interface for NIfTI data ## We are using 4 classes due to [background, lung_left, lung_right, covid-19] interface = NIFTI_interface(channels=1, classes=4) # Create Data IO object to load and write samples in the file structure data_io = Data_IO(interface, input_path="data", delete_batchDir=False) # Access all available samples in our file structure sample_list = data_io.get_indiceslist() sample_list.sort() # Split samples into k (training, validation) folds split_folds(sample_list, k_fold=i, evaluation_path="evaluation.cv" + str(i))
#-----------------------------------------------------# # Library imports # #-----------------------------------------------------# import tensorflow as tf from miscnn.data_loading.interfaces import NIFTI_interface from miscnn import Data_IO from miscnn.evaluation.cross_validation import split_folds #-----------------------------------------------------# # Tensorflow Configuration for GPU Cluster # #-----------------------------------------------------# # physical_devices = tf.config.list_physical_devices('GPU') # tf.config.experimental.set_memory_growth(physical_devices[0], True) #-----------------------------------------------------# # Running Preprocessing # #-----------------------------------------------------# # Initialize Data IO Interface for NIfTI data ## We are using 4 classes due to [background, lung_left, lung_right, covid-19] interface = NIFTI_interface(channels=1, classes=4) # Create Data IO object to load and write samples in the file structure data_io = Data_IO(interface, input_path="data", delete_batchDir=False) # Access all available samples in our file structure sample_list = data_io.get_indiceslist() sample_list.sort() # Split samples into k (training, validation) folds split_folds(sample_list, k_fold=5)