diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/logs/log_20241008_success.log b/logs/log_20241008_success.log new file mode 100644 index 0000000..c7a9beb --- /dev/null +++ b/logs/log_20241008_success.log @@ -0,0 +1,38 @@ + + + +/home/star/anaconda3/envs/pfcfuse/bin/python /home/star/whaiDir/PFCFuse/test_IVF.py + + +================================================================================ +The test result of TNO : +19.png +05.png +21.png +18.png +15.png +22.png +14.png +13.png +08.png +01.png +02.png +03.png +25.png +17.png +11.png +16.png +06.png +07.png +09.png +10.png +12.png +23.png +24.png +20.png +04.png + EN SD SF MI SCD VIF Qabf SSIM +PFCFuse 7.01 40.4 15.51 1.55 1.75 0.66 0.54 0.96 +================================================================================ + +Process finished with exit code 0 diff --git a/logs/status.md b/logs/status.md new file mode 100644 index 0000000..94c6302 --- /dev/null +++ b/logs/status.md @@ -0,0 +1,45 @@ +PFCFuse + + + + + +20241008 +``` +/home/star/anaconda3/envs/pfcfuse/bin/python /home/star/whaiDir/PFCFuse/test_IVF.py + + +================================================================================ +The test result of TNO : +19.png +05.png +21.png +18.png +15.png +22.png +14.png +13.png +08.png +01.png +02.png +03.png +25.png +17.png +11.png +16.png +06.png +07.png +09.png +10.png +12.png +23.png +24.png +20.png +04.png + EN SD SF MI SCD VIF Qabf SSIM +PFCFuse 7.01 40.4 15.51 1.55 1.75 0.66 0.54 0.96 +================================================================================ + +Process finished with exit code 0 + +``` diff --git a/test_IVF.py b/test_IVF.py index 4b84b1f..4505060 100644 --- a/test_IVF.py +++ b/test_IVF.py @@ -13,13 +13,14 @@ logging.basicConfig(level=logging.CRITICAL) os.environ["CUDA_VISIBLE_DEVICES"] = "0" -ckpt_path= r"models/PFCFuse.pth" +ckpt_path= r"PFCFuse_IVF.pth" + +for dataset_name in ["TNO","RoadScene"]: -for dataset_name in ["MSRS","TNO","RoadScene"]: print("\n"*2+"="*80) model_name="PFCFuse " print("The test result of "+dataset_name+' :') - test_folder=os.path.join('test_img',dataset_name) + test_folder=os.path.join('test_img',dataset_name) test_out_folder=os.path.join('test_result',dataset_name) device = 'cuda' if torch.cuda.is_available() else 'cpu' @@ -39,6 +40,7 @@ for dataset_name in ["MSRS","TNO","RoadScene"]: with torch.no_grad(): for img_name in os.listdir(os.path.join(test_folder,"ir")): + print(img_name) data_IR=image_read_cv2(os.path.join(test_folder,"ir",img_name),mode='GRAY')[np.newaxis,np.newaxis, ...]/255.0 data_VIS = cv2.split(image_read_cv2(os.path.join(test_folder, "vi", img_name), mode='YCrCb'))[0][np.newaxis, np.newaxis, ...] / 255.0 @@ -60,7 +62,7 @@ for dataset_name in ["MSRS","TNO","RoadScene"]: rgb_fi = cv2.cvtColor(ycrcb_fi, cv2.COLOR_YCrCb2RGB) img_save(rgb_fi, img_name.split(sep='.')[0], test_out_folder) - eval_folder=test_out_folder + eval_folder=test_out_folder ori_img_folder=test_folder metric_result = np.zeros((8)) diff --git a/test_shell.py b/test_shell.py new file mode 100644 index 0000000..09f2a5e --- /dev/null +++ b/test_shell.py @@ -0,0 +1,41 @@ +import os +import subprocess +import datetime +import sys + +# 定义命令 +command = "/home/star/anaconda3/envs/pfcfuse/bin/python /home/star/whaiDir/PFCFuse/test_IVF.py" + +# 获取当前时间并格式化为文件名 +current_time = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") +output_file = f"/home/star/whaiDir/PFCFuse/logs/ans_log_{current_time}.log" + +try: + # 打开文件用于写入 + with open(output_file, 'w') as log_file: + # 运行命令 + process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) + + # 循环读取输出 + for line in process.stdout: + # 同时打印到控制台和写入文件 + print(line.strip()) + log_file.write(line) + log_file.flush() # 确保立即写入文件 + + # 等待命令完成 + process.wait() + + # 检查返回码 + if process.returncode != 0: + raise subprocess.CalledProcessError(process.returncode, command) + + # 如果命令成功执行,则打印确认信息 + print(f"Command executed successfully. Output has been written to {output_file}") + +except subprocess.CalledProcessError as e: + # 如果命令执行失败,则删除文件并打印错误信息 + if os.path.exists(output_file): + os.remove(output_file) + print(f"Command failed with return code {e.returncode}. No log file was created.")