From eeb507ec18b7a206bac6bbf35e338d6e0e98fe11 Mon Sep 17 00:00:00 2001 From: "xiangyu.xie" Date: Thu, 28 May 2026 16:34:17 +0200 Subject: [PATCH] Update script conventions --- Configs/infer_1photon.yaml | 12 +++++------- Configs/infer_2photon.yaml | 28 ++++++++++++++++++++++++---- Infer_2Photon.py | 5 +++-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Configs/infer_1photon.yaml b/Configs/infer_1photon.yaml index e5ede71..9306a7a 100644 --- a/Configs/infer_1photon.yaml +++ b/Configs/infer_1photon.yaml @@ -1,6 +1,6 @@ # configs/infer_1photon.yaml experiment: - name: "FlatField_3filters_pos0" # options: SiemenStarLowerLeft, SiemenStarLowerRight + name: "FlatField_2filters" # options: SiemenStarLowerLeft, SiemenStarLowerRight task: "1Photon" output_base: "./InferenceResults" @@ -29,7 +29,7 @@ data: file_pattern: "2603MaxIV_FlatField3Filters_pos0_12keV/1Photon_CS3_chunk{}.h5" ### 12 keV NX: 101 NY: 101 - file_range: [0, 48] # [0, 48) + file_range: [0, 16] # [0, 16) roi: [0, 101, 0, 101] KnifeEdge_2filters: file_pattern: "2603MaxIV_Edge2Filters_12keV/1Photon_CS3_chunk{}.h5" ### 12 keV @@ -58,13 +58,11 @@ data: model: base_dir: "/home/xie_x1/MLXID/DeepLearning/Results/" # 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" + # name: "singlePhoton251022_12keV_Noise0.13keV_E150_aug1.pth" ### std/mean = 0.033 experiment_name: "260512_1ph_12keV_v260511_06" - name: "singlePhoton260511_12keV_Noise0.13keV_E300_aug1.pth" + name: "singlePhoton260511_12keV_Noise0.13keV_E500_aug1.pth" ### std/mean = 0.025 inference: binning_factor: 10 chunk_size: 16 # - num_aug_ops: 8 # TTA: test-time augmentation + num_aug_ops: 1 # TTA: test-time augmentation diff --git a/Configs/infer_2photon.yaml b/Configs/infer_2photon.yaml index 4befca8..a9d8108 100644 --- a/Configs/infer_2photon.yaml +++ b/Configs/infer_2photon.yaml @@ -32,7 +32,28 @@ data: file_pattern: "2603MaxIV_FlatField3Filters_pos0_12keV/2Photon_CS7_chunk{}.h5" ### 12 keV NX: 101 NY: 101 - file_range: [0, 48] # [0, 48) + file_range: [0, 16] # [0, 16) + roi: [0, 101, 0, 101] + nSize: 7 + KnifeEdge_2filters: + file_pattern: "2603MaxIV_Edge2Filters_12keV/2Photon_CS7_chunk{}.h5" ### 12 keV + NX: 101 + NY: 101 + file_range: [0, 16] # [0, 16) + roi: [0, 101, 0, 101] + nSize: 7 + FlatField_2filters: + file_pattern: "2603MaxIV_Flat2Filters_12keV/2Photon_CS7_chunk{}.h5" ### 12 keV + NX: 101 + NY: 101 + file_range: [0, 16] # [0, 16) + roi: [0, 101, 0, 101] + nSize: 7 + Uniformity_test: + file_pattern: "2603MaxIV_Flat2Filters_12keV/2Photon_CS7_chunk{}.h5" ### 12 keV + NX: 101 + NY: 101 + file_range: [0, 1] roi: [0, 101, 0, 101] nSize: 7 @@ -42,10 +63,9 @@ data: num_workers: 16 model: - version: "251124" base_dir: "/home/xie_x1/MLXID/DeepLearning/Results/" - experiment_name: "260506_2ph_12keV_v251124_03" - name: "doublePhoton251124_12keV_Noise0.13keV_E150.pth" + experiment_name: "260511_2ph_12keV_v260507_00" + name: "doublePhoton260507_12keV_Noise0.13keV_E300.pth" inference: binning_factor: 10 diff --git a/Infer_2Photon.py b/Infer_2Photon.py index 695a5de..5f42079 100644 --- a/Infer_2Photon.py +++ b/Infer_2Photon.py @@ -140,7 +140,7 @@ def save_results(ml_super_frame, count_frame, subpixel_dist, plt.close() np.save(output_dir / '2Photon_subpixel_Distribution.npy', subpixel_dist) std, mean = np.std(subpixel_dist), np.mean(subpixel_dist) - print(f"[Plotting]: Sub-pixel distribution: Std/Mean: {std/mean:.4f}") + print(f"[Plotting]: Sub-pixel distribution: RMS/Mean: {std/mean:.4f}, expected value = {1/np.sqrt(mean):.4f} for uniform distribution") print(f"Results saved to: {output_dir}") @@ -149,7 +149,8 @@ if __name__ == "__main__": output_dir = prepare_output_folder(conf) ### model loading - model = get_double_photon_model_class(conf.model.version)().cuda() + model_version = conf.model.experiment_name.split('_v')[-1][:6] + model = get_double_photon_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()