DeblurGAN 安装调试笔记

DeblurGAN  消除运动模糊

源码地址

https://github.com/KupynOrest/DeblurGAN

下载 weight 文件(dropbox 网盘下不了的,可以找我要。

原链接的 latest_net_G.pth  文件莫名消失了,下载见下面。

链接: https://pan.baidu.com/s/1nvQQNGH 密码: 8ab2

要 latest_net_D.pth 的朋友也不少,上传一下。

链接: https://pan.baidu.com/s/14Lq2YUYoeDYRslgUbShZNQ 密码: k4j5

下载安装 pytorch

http://pytorch.org/

选择系统和安装方式
执行后,下载很慢,迅雷下好后上传。
sudo pip3 install torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl
sudo pip3 install torchvision

test.py 里 SSIM  直接  import ssim 就好

NameError: name 'use_parallel' is not defined

models/test_model.py   里  的  use_parallel 替换为 True。

test 命令

python3 test.py --dataroot ./testimage  --model test --dataset_mode single --learn_residual --resize_or_crop scale_width

testimage 是存放图片的目录,–resize_or_crop  scale_width 是保持图片原大小。

加 scale_width 后 处理有些图片时显示如下错误

RuntimeError: invalid argument 3: sizes do not match at /pytorch/torch/lib/THC/generated/../generic/THCTensorMathPointwise.cu:217

resize_or_crop 也可以选择  false ,但是容易爆内存。内存不足的时候推荐用 resize_and_crop

去模糊效果很不错

 

 

和 SR 一起处理的效果

待解之谜:不知道怎么能跑成翻转图像,很神奇。

终于试出来了,去掉

--learn_residual

就能出现这个效果。

效果:

原图

重新 clone 代码后正常,问题可能是某个参数错了,或文件损坏。

 

人比人得死。贾佳亚 的 Robust Motion Deblurring 效果。

《DeblurGAN 安装调试笔记》上有62条评论

  1. 您好,我最近也在研究这篇论文,我跑代码时报错
    serial_batches: False
    which_direction: AtoB
    which_epoch: latest
    which_model_netD: basic
    which_model_netG: resnet_9blocks
    ————– End —————-
    CustomDatasetDataLoader
    dataset [SingleImageDataset] was created
    Traceback (most recent call last):
    File “test.py”, line 21, in
    model = create_model(opt)
    File “/home/gh/Downloads/DeblurGAN-master/models/models.py”, line 11, in create_model
    model.initialize(opt)
    File “/home/gh/Downloads/DeblurGAN-master/models/test_model.py”, line 19, in initialize
    opt.learn_residual)
    File “/home/gh/Downloads/DeblurGAN-master/models/networks.py”, line 52, in define_G
    netG.cuda(device_id=gpu_ids[0])
    TypeError: cuda() got an unexpected keyword argument ‘device_id’
    不知您是否可以了解?
    还有我在下weight时,发现只有一个weight了,我记得有一个G一个D的,现在只有D了,我用D跑测试是否可以

  2. 您好,最近也在研究这个论文,在跑test测试时,碰到了这个问题
    Traceback (most recent call last):
    File “test.py”, line 21, in
    model = create_model(opt)
    File “/home/std/wJ/work5/DeblurGAN-master/models/models.py”, line 11, in create_model
    model.initialize(opt)
    File “/home/std/wJ/work5/DeblurGAN-master/models/test_model.py”, line 21, in initialize
    self.load_network(self.netG, ‘G’, which_epoch)
    File “/home/std/wJ/work5/DeblurGAN-master/models/base_model.py”, line 53, in load_network
    network.load_state_dict(torch.load(save_path))
    File “/home/std/anaconda2/envs/PYtorch/lib/python3.5/site-packages/torch/serialization.py”, line 259, in load
    f = open(f, ‘rb’)
    FileNotFoundError: [Errno 2] No such file or directory: ‘./checkpoints/experiment_name/latest_net_G.pth’
    请问您是怎么解决的。github上只提供了一个latest_net_D.pth

  3. 你当初在github上下的项目文件都够吗?发现现在下载的不全啊,权重weights文件都不知道往哪个地方放。你的项目文件中有下面这个路径吗?/.checkpoints/experiment_name

      1. 你好,我这条件有限,我用的是谷歌云盘那个免费GPU,但是我看你的项目文件中有下面这个路径吗?/.checkpoints/experiment_name,我不知道下载好的latest_net_G.pth放在哪里?而我的电脑系统是win7,我也找不到这个根目录,麻烦指教一下,谢谢

        1. 你好,这里我进行combine_A_andB.py的时候总会出现这个问题:NotADirectoryError: [Errno 20] Not a directory: ‘/DeblurGAN-master/datasets/dataset/A/0019.png’ 或者我删除这个照片也会出现其他照片出现这个问题?您能跟我说一下这个怎么解决?

  4. 楼主,我在跑训练的程序的时候会出现autograd.grad has no attribute grad 的错误,请问是为什么?

  5. 楼主,我在跑训练的程序的时候会出现autograd.grad has no attribute grad 的错误,请问是为什么?

  6. 您好 我在做训练的时候 先创建图像对的时候 总是相同的图像进行 建立两个文件夹 都是文件夹内的图像自己创建图相对;这是正确的结果吗?而且在运行trian.py的时候报错 train.py: error: argument –fine Size: invalid int value: ‘CROP_SIZE 请教一下您这个问题怎么处理

  7. 你好,我在进行combine_A_and_B.py的时候总是出现NotADirectoryError: [Errno 20] Not a directory: ‘/DeblurGAN-master/datasets/dataset/A/0019.png’相关的图片问题,请教一下问什么?路径也没有出错啊

    1. 发下你执行的命令。另提示也不是路径错误啊,这错误的意思是这个地方应该出现一个目录,但是却是个文件。

  8. 请问楼主是否遇到这个问题
    Traceback (most recent call last):
    File “/home4/liutao/software/anaconda3/lib/python3.6/site-packages/urllib3/connection.py”, line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
    File “/home4/liutao/software/anaconda3/lib/python3.6/site-packages/urllib3/util/connection.py”, line 83, in create_connection
    raise err
    File “/home4/liutao/software/anaconda3/lib/python3.6/site-packages/urllib3/util/connection.py”, line 73, in create_connection
    sock.connect(sa)
    ConnectionRefusedError: [Errno 111] Connection refused

  9. 请教一下关于用自己的图片进行训练时,图片的文件夹如何设计呢?可以讲解一下吗?还有您上边弄得两个网盘里的权重,可以发一下整体的文件目录是怎样放的吗?谢谢!

  10. 您好,我想问一下在运行test.py文件时候遇到下面问题
    Traceback (most recent call last):
    File “test.py”, line 6, in
    from util.visualizer import Visualizer
    File “/data/wangfangjun/wyr/DeblurGAN-master/DeblurGAN-master/util/visualizer.py”, line 6, in
    from . import html
    File “/data/wangfangjun/wyr/DeblurGAN-master/DeblurGAN-master/util/html.py”, line 1, in
    import dominate
    ImportError: No module named dominate
    但网站上没有dominate文件,能不能分享一下?谢谢!!

  11. 您好,运行test.py时候报错,但在GitHub上没有叫dominate的文件,请问您能分享一下吗?谢谢
    Traceback (most recent call last):
    File “test.py”, line 6, in
    from util.visualizer import Visualizer
    File “/data/wangfangjun/wyr/DeblurGAN-master/DeblurGAN-master/util/visualizer.py”, line 6, in
    from . import html
    File “/data/wangfangjun/wyr/DeblurGAN-master/DeblurGAN-master/util/html.py”, line 1, in
    import dominate
    ImportError: No module named dominate

  12. 出现了这样一个问题
    ‘SingleDataset’ object has no attribute ‘A_paths’

    不知道如何解决呢,谢谢

  13. 您好,我想问一下在运行test.py文件时候遇到下面问题
    Traceback (most recent call last):
    File “test.py”, line 6, in
    from util.visualizer import Visualizer
    File “/data/wangfangjun/wyr/DeblurGAN-master/DeblurGAN-master/util/visualizer.py”, line 6, in
    from . import html
    File “/data/wangfangjun/wyr/DeblurGAN-master/DeblurGAN-master/util/html.py”, line 1, in
    import dominate
    ImportError: No module named dominate
    但网站上没有dominate文件,能不能分享一下?谢谢!!

  14. 您好,请问“跑成神奇的翻转图像”其中的“翻转图像”是什么意思呢?

    期待您的回复!

  15. The size of tensor a (333) must match the size of tensor b (336) at non-singleton dimension 2
    你好请问下你知道这个是怎么回事么?

  16. 您好,请问复现时输入640*480图像,输出结果为什么变成了256*192?您知道这是怎么回事吗?

  17. 你好能给我发一下权重数据吗?另外我想请教一些问题能不能方便加个联系方式,谢谢了,我的QQ号和邮箱地址一样

  18. 博主,你好,请问为什么我加载你的权重文件后和网络对不上,unexpected key “model.10.conv_block.6.weight,出现上述错误

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据