SRFBN的PyTorch实现
源码:https://github.com/Paper99/SRFBN_CVPR19
依赖项:
- Python 3 (Anaconda is recommended)
- skimage
- imageio
- Pytorch (Pytorch version >=0.4.1 is recommended)
- tqdm
- pandas
- cv2 (pip install opencv-python)
- Matlab
目录
1 用现有模型测试
1.1 快速测试
1.1.1 下载项目。
git clone https://github.com/Paper99/SRFBN_CVPR19.git
1.1.2 下载预训练模型,解压缩模型并将它们放到 ./models 中。
1.1.3 在 SRFBN_CVPR19-master 目录下,运行以下命令之一,在Set5上进行评估。
# SRFBN
python test.py -opt options/test/test_SRFBN_x2_BI.json
python test.py -opt options/test/test_SRFBN_x3_BI.json
python test.py -opt options/test/test_SRFBN_x4_BI.json
python test.py -opt options/test/test_SRFBN_x3_BD.json
python test.py -opt options/test/test_SRFBN_x3_DN.json
# SRFBN-S
python test.py -opt options/test/test_SRFBN-S_x2_BI.json
python test.py -opt options/test/test_SRFBN-S_x3_BI.json
python test.py -opt options/test/test_SRFBN-S_x4_BI.json
例如:运行 python test.py -opt options/test/test_SRFBN_x2_BI.json (红框中参数可对应修改)。结果保存在 ./results/SR/BI/SRFBN/Set5/x2 中。Set5 的 PSNR/SSIM 值显示在屏幕上。
1.2 测试标准的 SRbenchmark 和自己的图像
1.2.1 完成 1.1.1 和 1.1.2 ,下载 SRbenchmark 数据集。
SR benchmark (Set5, Set14, B100, Urban100 and Manga109) BaiduYun(code:z6nz)
1.2.2 在 SRFBN_CVPR19-master 目录下,解压 SRbenchmark,生成 SRbenchmark 测试数据集。
使用 matlab 打开 ./results/Prepare_TestData_HR_LR.m,生成适用不同退化模型的 HR/LR 图像,保存在 ./results 相应位置中。
1.2.3 参考 ./options/test/README.md ,根据需要修改 ./options/test/test_SRFBN_example.json。
将自己的图像放入 ./results/LR/MyImage 中,与 Set14 数据集一同使用现有的预训练模型进行测试。
1.2.4 在 SRFBN_CVPR19-master 目录下,运行以下命令。
python test.py -opt options/test/test_SRFBN_example.json
图像数据集的 PSNR/SSIM 值会在屏幕上显示,重建图像在 ./results/SR 中。
2 训练模型测试自己的数据集
2.1 生成训练、验证数据集训练模型
2.1.1 在 ./datasets 中新建 Ship_train_HR 文件夹存放待训练的 HR 图像。
2.1.2 使用 matlab 打开 ./scripts/Prepare_TrainData_HR_LR.m,修改相应参数生成训练 HR/LR 图像。
2.1.3 在 SRbenchmark 中新建 Ship 文件夹存放待验证的 HR 图像。
2.1.4 使用 matlab 打开 ./results/Prepare_TestData_HR_LR.m,修改相应参数生成的 HR/LR 图像作为验证集。
2.1.5 参考 ./options/train/README.md ,复制粘贴 ./options/train/train_SRFBN_example.json,重命名为 train_SRFBN_mine.json 并修改。
2.1.6 在 SRFBN_CVPR19-master 目录下,运行以下命令。
python train.py -opt options/train/train_SRFBN_mine.json
训练完后的模型文件保存在 ./experiments/SRFBN_in3f32_x2/epochs 中。
2.2 测试自己的数据集
2.2.1 将测试图像放入 ./results/LR/MyImage 中,复制粘贴 ./options/test/test_SRFBN_example.json,重命名为 test_SRFBN_mine.json 并修改。
训练模型时:"scale": 2,"degradation": "BI"。
2.2.2 在 SRFBN_CVPR19-master 目录下,运行以下命令进行测试。
python test.py -opt options/test/test_SRFBN_mine.json