diff --git a/Configs/infer_1photon.yaml b/Configs/infer_1photon.yaml index ffce71f..e5ede71 100644 --- a/Configs/infer_1photon.yaml +++ b/Configs/infer_1photon.yaml @@ -31,6 +31,24 @@ data: NY: 101 file_range: [0, 48] # [0, 48) roi: [0, 101, 0, 101] + KnifeEdge_2filters: + file_pattern: "2603MaxIV_Edge2Filters_12keV/1Photon_CS3_chunk{}.h5" ### 12 keV + NX: 101 + NY: 101 + file_range: [0, 16] # [0, 16) + roi: [0, 101, 0, 101] + FlatField_2filters: + file_pattern: "2603MaxIV_Flat2Filters_12keV/1Photon_CS3_chunk{}.h5" ### 12 keV + NX: 101 + NY: 101 + file_range: [0, 16] # [0, 16) + roi: [0, 101, 0, 101] + Uniformity_test: + file_pattern: "2603MaxIV_Flat2Filters_12keV/1Photon_CS3_chunk{}.h5" ### 12 keV + NX: 101 + NY: 101 + file_range: [0, 1] + roi: [0, 101, 0, 101] energy: 12 # keV normalize: false # for inference dataloaders @@ -38,13 +56,15 @@ data: num_workers: 16 model: - version: "251022" base_dir: "/home/xie_x1/MLXID/DeepLearning/Results/" - experiment_name: "260408_1ph_12keV_v251022_03" - name: "singlePhoton251022_12keV_Noise0.13keV_E150_aug1.pth" - noise_keV: 0.13 + # experiment_name: "260408_1ph_12keV_v251022_03" + # name: "singlePhoton251022_12keV_Noise0.13keV_E150_aug1.pth" + # experiment_name: "260511_1ph_12keV_v251022_00" + # name: "singlePhoton251022_12keV_Noise0.13keV_E150_aug1.pth" + experiment_name: "260512_1ph_12keV_v260511_06" + name: "singlePhoton260511_12keV_Noise0.13keV_E300_aug1.pth" inference: binning_factor: 10 - chunk_size: 16 # + chunk_size: 16 # num_aug_ops: 8 # TTA: test-time augmentation diff --git a/Infer_1Photon.py b/Infer_1Photon.py index 16b5f1a..93a694c 100644 --- a/Infer_1Photon.py +++ b/Infer_1Photon.py @@ -60,7 +60,6 @@ def get_files_list(conf): return files def run_inference(model, data_loader, conf): - model.eval() all_predictions = [] all_reference_points = data_loader.dataset.referencePoint with torch.no_grad(): @@ -144,7 +143,7 @@ def save_results(ml_super_frame, count_frame, subpixel_dist, plt.close() np.save(output_dir / '1Photon_subpixel_Distribution.npy', subpixel_dist) rms, mean = np.std(subpixel_dist), np.mean(subpixel_dist) - print(f"[Plotting]: Sub-pixel distribution: RMS/Mean: {rms/mean:.4f}") + print(f"[Plotting]: Sub-pixel distribution: RMS/Mean: {rms/mean:.4f}, expected value = {1/np.sqrt(mean):.4f} for uniform distribution") print(f"Results saved to: {output_dir}") @@ -153,7 +152,8 @@ if __name__ == "__main__": output_dir = prepare_output_folder(conf) ### model loading - model = get_model_class(conf.model.version)().cuda() + model_version = conf.model.experiment_name.split('_v')[-1][:6] + model = get_model_class(model_version)().cuda() model.load_state_dict(torch.load(f'{conf.model.base_dir}/{conf.model.experiment_name}/Models/{conf.model.name}', weights_only=True)) model.eval()