# PyTorch SRResNet
Implementation of Paper: "Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network"(https://arxiv.org/abs/1609.04802) in PyTorch
## Usage
### Training
```
usage: main_srresnet.py [-h] [--batchSize BATCHSIZE] [--nEpochs NEPOCHS]
[--lr LR] [--step STEP] [--cuda] [--resume RESUME]
[--start-epoch START_EPOCH] [--threads THREADS]
[--pretrained PRETRAINED] [--vgg_loss] [--gpus GPUS]
optional arguments:
-h, --help show this help message and exit
--batchSize BATCHSIZE
training batch size
--nEpochs NEPOCHS number of epochs to train for
--lr LR Learning Rate. Default=1e-4
--step STEP Sets the learning rate to the initial LR decayed by
momentum every n epochs, Default: n=500
--cuda Use cuda?
--resume RESUME Path to checkpoint (default: none)
--start-epoch START_EPOCH
Manual epoch number (useful on restarts)
--threads THREADS Number of threads for data loader to use, Default: 1
--pretrained PRETRAINED
path to pretrained model (default: none)
--vgg_loss Use content loss?
--gpus GPUS gpu ids (default: 0)
```
An example of training usage is shown as follows:
```
python main_srresnet.py --cuda --vgg_loss --gpus 0
```
### demo
```
usage: demo.py [-h] [--cuda] [--model MODEL] [--image IMAGE]
[--dataset DATASET] [--scale SCALE] [--gpus GPUS]
optional arguments:
-h, --help show this help message and exit
--cuda use cuda?
--model MODEL model path
--image IMAGE image name
--dataset DATASET dataset name
--scale SCALE scale factor, Default: 4
--gpus GPUS gpu ids (default: 0)
```
We convert Set5 test set images to mat format using Matlab, for simple image reading
An example of usage is shown as follows:
```
python demo.py --model model/model_srresnet.pth --dataset Set5 --image butterfly_GT --scale 4 --cuda
```
### Eval
```
usage: eval.py [-h] [--cuda] [--model MODEL] [--dataset DATASET]
[--scale SCALE] [--gpus GPUS]
optional arguments:
-h, --help show this help message and exit
--cuda use cuda?
--model MODEL model path
--dataset DATASET dataset name, Default: Set5
--scale SCALE scale factor, Default: 4
--gpus GPUS gpu ids (default: 0)
```
We convert Set5 test set images to mat format using Matlab. Since PSNR is evaluated on only Y channel, we import matlab in python, and use rgb2ycbcr function for converting rgb image to ycbcr image. You will have to setup the matlab python interface so as to import matlab library.
An example of usage is shown as follows:
```
python eval.py --model model/model_srresnet.pth --dataset Set5 --cuda
```
### Prepare Training dataset
- Please refer [Code for Data Generation](https://github.com/twtygqyy/pytorch-SRResNet/tree/master/data) for creating training files.
- Data augmentations including flipping, rotation, downsizing are adopted.
### Performance
- We provide a pretrained model trained on [291](http://cv.snu.ac.kr/research/VDSR/train_data.zip) images with data augmentation
- Instance Normalization is applied instead of Batch Normalization for better performance
- So far performance in PSNR is not as good as paper, any suggestion is welcome
| Dataset | SRResNet Paper | SRResNet PyTorch|
| :-------------:|:--------------:|:---------------:|
| Set5 | 32.05 | **31.80** |
| Set14 | 28.49 | **28.25** |
| BSD100 | 27.58 | **27.51** |
### Result
From left to right are ground truth, bicubic and SRResNet
<p>
<img src='result/result.png' height='260' width='700'/>
</p>
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
配套文章:https://blog.csdn.net/qq_36584673/article/details/136875838 编译器:anaconda + pycharm pytorch环境:torch1.9.1+cuda11.1 再安装好所需的包即可运行。 文件目录: checkpoint:存放训练过程中的模型文件 data:h5格式训练集位置,生成h5格式训练集的matlab代码 model:作者给出的模型文件位置 testsets:测试集,有Set5和Set14 dataset.py:将h5数据集转成DataLoader的输入格式 demo.py:可视化测试图像的超分结果,和Bicubic对比 eval.py:评估测试集,计算平均PSNR main_serresnet.py:训练SRResNet srresnet.py:SRResNet模型定义 使用方法: 1.执行main_serresnet.py训练LapSRN 2.执行eval.py计算Set5的平均PSNR 3.执行demo.py可视化超分结果对比并计算单张图像的PSNR
资源推荐
资源详情
资源评论
收起资源包目录
pytorch-SRResNet-master.zip (45个子文件)
pytorch-SRResNet-master
checkpoint
model_epoch_500_LeakyReLU.pth 5.95MB
model_epoch_500_PReLU.pth 5.96MB
eval.py 4KB
data
generate_train_srresnet.m 3KB
store2hdf5.m 3KB
modcrop.m 267B
LICENSE 1KB
dataset.py 508B
main_srresnet.py 7KB
.idea
pytorch-SRResNet-master.iml 582B
other.xml 200B
workspace.xml 5KB
misc.xml 371B
inspectionProfiles
profiles_settings.xml 174B
modules.xml 305B
deployment.xml 2KB
.gitignore 50B
testsets
butterfly_GT_SRResNet_plt.png 655KB
butterfly_GT_SRResNet_x4.png 114KB
Set5
bird_GT.mat 3.25MB
butterfly_GT.mat 2.61MB
woman_GT.mat 3.06MB
baby_GT.mat 10.26MB
head_GT.mat 2.68MB
Set14
face.mat 2.6MB
zebra.mat 9.09MB
flowers.mat 7.17MB
foreman.mat 3.75MB
baboon.mat 8.52MB
monarch.mat 15.22MB
coastguard.mat 3.87MB
man.mat 9.17MB
pepper.mat 10.59MB
barbara.mat 16.75MB
lenna.mat 9.02MB
bridge.mat 8.85MB
comic.mat 3.6MB
ppt3.mat 8.48MB
srresnet.py 5KB
model
model_srresnet.pth 5.97MB
__pycache__
srresnet.cpython-38.pyc 4KB
dataset.cpython-38.pyc 1KB
demo.py 3KB
README.md 4KB
result
result.png 662KB
共 45 条
- 1
资源评论
- 一帆风顺7122024-04-25资源内容详尽,对我有使用价值,谢谢资源主的分享。
- benti7212024-05-02资源很不错,内容和描述一致,值得借鉴,赶紧学起来!
- 2301_774807192024-04-29感谢大佬分享的资源给了我灵感,果断支持!感谢分享~
十小大
- 粉丝: 9992
- 资源: 2555
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功