'model_file': os.path.join(model_dir, 'Xception-004-0.984.hdf5'), 'input_shape': (299, 299, 3), 'model_weight': 1 } dicts_models.append(dict_model1) filename_csv = os.path.join(dir_dest, 'LaserSpot_predict_dir.csv') if GEN_CSV: os.makedirs(os.path.dirname(filename_csv), exist_ok=True) write_csv_dir_nolabel(filename_csv, dir_preprocess) df = pd.read_csv(filename_csv) all_files, all_labels = get_images_labels(filename_csv_or_pd=df) prob_total, y_pred_total, prob_list, pred_list = \ do_predict(dicts_models, filename_csv, argmax=True) import pickle os.makedirs(os.path.dirname(pkl_prob), exist_ok=True) with open(pkl_prob, 'wb') as file: pickle.dump(prob_total, file) if COMPUTE_DIR_FILES: op_files_multiclass(filename_csv, prob_total, dir_preprocess=dir_preprocess, dir_dest=dir_dest, dir_original=dir_original, keep_subdir=True) print('OK')
# prob_total = pickle.load(pkl_file) if COMPUTE_CONFUSIN_MATRIX: (cf_list, not_match_list, cf_total, not_match_total) = \ my_confusion_matrix.compute_confusion_matrix(prob_list, dir_dest_confusion, all_files, all_labels, dir_preprocess=dir_crop_optic_disc, dir_original=dir_original) if not os.path.exists(os.path.dirname(pkl_confusion_matrix)): os.makedirs(os.path.dirname(pkl_confusion_matrix)) with open(pkl_confusion_matrix, 'wb') as file: pickle.dump(cf_total, file) if COMPUTE_DIR_FILES: my_multi_class.op_files_multiclass(filename_csv, prob_total, dir_preprocess=dir_crop_optic_disc, dir_dest=dir_dest_predict_dir, dir_original=dir_original, keep_subdir=True) print('OK') ''' confusion train: [1102,73] [46,956] validation: [203,12] [9,161] '''