超分辨率总结

优秀代码路径

@misc{cardinale2018isr,
title={ISR},
author={Francesco Cardinale et al.},
year={2018},
howpublished={\url{https://github.com/idealo/image-super-resolution}},
}

{https://github.com/idealo/image-super-resolution

https://paperswithcode.com/task/image-super-resolution

https://paperswithcode.com/sota/image-super-resolution-on-set5-4x-upscaling

SwinIR

Image Restoration Using Swin Transformer
https://github.com/JingyunLiang/SwinIR

https://paperswithcode.com/paper/swinir-image-restoration-using-swin
D:\hujianhua\科研与社会服务\论文\超分辨率\代码\SwinIR-main

另外一个版本,有训练代码:
https://github.com/skchen1993/SwinIR
https://arxiv.org/abs/2108.10257?context=eess.IV

这一版本有训练代码:
D:\hujianhua\科研与社会服务\论文\超分辨率\代码\SwinIR-train\SwinIR-main
pip install wandb -i https://pypi.tuna.tsinghua.edu.cn/simple

如果只是测试代码,只需要下载(默认下载代码只有):
models/network_swinir.py, utils/util_calculate_psnr_ssim.py and main_test_swinir.py

官方训练代码

https://github.com/cszn/KAIR

D:\lunwen\超分辨率\代码\KAIR-master

Pip install -r requirement.txt

lte

Local Texture Estimator for Implicit Representation Function
D:\hujianhua\科研与社会服务\论文\超分辨率\代码\lte-main\lte-main

https://github.com/jaewon-lee-b/lte

No module named ‘torch’

pip install torch -I https://pypi.tuna.tsinghua.edu.cn/simple
pip install torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install tensorboardX -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install timm -i https://pypi.tuna.tsinghua.edu.cn/simple

lte-main\lte-main\load\div2k

预训练模型:
D:\hujianhua\科研与社会服务\论文\超分辨率\代码\lte-main\swinir-lte.pth

在服务器上创建一个python脚本 t.py:
?
import torch
print(torch.cuda.device_count())
#可用gpu数量
print(torch.cuda.is_available()) # #是否可用gpu

PyTorch中如何用GPU进行训练

https://blog.csdn.net/weixin_40692714/article/details/122748693
if torch.cuda.is_available():

在GPU与CPU之间切换。
if torch.cuda.is_available(): # hujianhua
gt_sub = torch.FloatTensor(t[‘sub’]).view(1, 1, -1).cuda()
gt_div = torch.FloatTensor(t[‘div’]).view(1, 1, -1).cuda()
else:
gt_sub = torch.FloatTensor(t[‘sub’]).view(1, 1, -1).cuda()
gt_div = torch.FloatTensor(t[‘div’]).view(1, 1, -1).cuda()

预训练模型。

D:\hujianhua\科研与社会服务\论文\超分辨率\代码\lte-main\lte-main\save\ swinir-lte.pth

文中分别使用了三个网络,并且在此基础上做了提高。

SWINIR:Jingyun Liang, Jiezhang Cao, Guolei Sun, Kai Zhang, Luc
Van Gool, and Radu Timofte. SwinIR: Image Restoration
Using Swin Transformer. In Proceedings of the IEEE/CVF
International Conference on Computer Vision (ICCV) Work
shops, pages 1833–1844, October 2021.

EDSR: Bee Lim, Sanghyun Son, Heewon Kim, Seungjun Nah, and
Kyoung Mu Lee. Enhanced Deep Residual Networks for
Single Image Super-Resolution. In Proceedings of the IEEE
Conference on Computer Vision and Pattern Recognition
(CVPR) Workshops, July 2017

RDN: Yulun Zhang, Yapeng Tian, Yu Kong, Bineng Zhong,
and Yun Fu. Residual Dense Network for Image Super
Resolution. In Proceedings of the IEEE Conference on Com
puter Vision and Pattern Recognition (CVPR), June 2018

SwinIR-LTE 训练与测试
训练模型
Train: python train.py --config configs/train-div2k/train_swinir-lte.yaml --gpu 0,1,2,3
Test: python test.py --config configs/test/test-div2k-2.yaml --model save/_train_swinir-lte/epoch-last.pth --window 8 --gpu 0

测试单个图像:
python demo.py --input ./demo/Urban100_img012x2.png --model save/edsr-baseline-lte.pth --scale 2 --output output.png --gpu 0

python demo.py --input ./demo/Urban100_img012x2.png --model save_configs\train-div2k\ epoch-last.pth --scale 2 --output output.png

–input ./demo/Urban100_img012x2.png --model .\save_configs\train-div2k\train_rdn-lte\epoch-last.pth --scale 2 --output output.png

运行成功,在目录下生成output.png

–input ./demo/Urban100_img012x2.png --model .\save_configs\train-div2k\train_rdn-lte\epoch-last.pth --scale 2 --output output.png

–input ./demo/1.png --model save/epoch-300.pth --scale 2 --output output.png

参数错误原因:

https://blog.csdn.net/t20134297/article/details/110533007

1.作用:用来加载torch.save() 保存的模型文件。
torch.load()先在CPU上加载,不会依赖于保存模型的设备。如果加载失败,可能是因为没有包含某些设备,比如你在gpu上训练保存的模型,而在cpu上加载,可能会报错,此时,需要使用map_location来将存储动态重新映射到可选设备上,比如map_location=torch.device(‘cpu’),意思是映射到cpu上,在cpu上加载模型,无论你这个模型从哪里训练保存的。

model = models.make(torch.load(args.model, map_location=‘cpu’)[‘model’], load_sd=True)

cmdline = r"python demo.py --input ./demo/Urban100_img012x2.png --model save/swinir-lte.pth --scale 2 --output output.png"

测试PSNR

Test:
python test.py --config configs/test/test-div2k-2.yaml --model save/swinir-lte.pth --window 8 --gpu 0

–config configs/test/test-div2k-2.yaml --model save/swinir-lte.pth --window 8

修改test-div2k-2.yaml:
root_path_1: load/Set5/LRbicx2
root_path_2: load/Set5/original

model = torch.load(model_path, map_location=‘cpu’)

没有cuda时,记得加上map_location=‘cpu’,要不然会报错

查看模型结构
https://blog.csdn.net/LaLaLaLaXFF/article/details/122867833
pip install torchsummary -i https://pypi.tuna.tsinghua.edu.cn/simple

from torchsummary import summary
summary(model, (8, 3))

summary(model, (3, 224, 224))

#hujianhua

for n in model.modules():

print(n)

使用下载的预训练模型

D:\hujianhua\科研与社会服务\论文\超分辨率\代码\lte-main\lte-main\save\ swinir-lte.pth

–input ./demo/Urban100_img012x2.png --model .\save\ swinir-lte.pth --scale 2 --output output.png

论文总结

图像恢复 SWinIR : 彻底理解论文和源代码

https://blog.csdn.net/Wenyuanbo/article/details/121264131

通过参数名字来选择模型结构
def make(model_spec, args=None, load_sd=False):
model = modelsmodel_spec[‘name’]
注册模型
@register(‘swinir’)
def make_swinir(no_upsampling=True):
return SwinIR()

模型定义:
class SwinIR(nn.Module):

最近关于隐式神经功能的研究揭示了这一点以任意分辨率表示图像。然而
一个独立的多层感知器在学习高频成分方面表现有限。
在本文中,我们提出了一种局部纹理估计器(LTE)自然图像的主频估计器
这是一个隐式函数,用于在连续重建图像的同时捕捉细节。当共同
使用深度超分辨率(SR)时,可以使LTE能够在二维傅里叶空间变换中描述图像纹理
我们证明了基于LTE的神经功能可以实现与现有的深度SR方法相比,性能良好
在任意比例因子内。此外,我们还证明,我们的实现运行时间最短与以前的作品相比
batched_predict->model.gen_feat(inp)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风口上的传奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值