DeniJsonC / WaveNet

[PG 2023] WaveNet: Wave-Aware Image Enhancement
Other
78 stars 14 forks source link

5k权重不匹配 #17

Closed ycwsilent closed 1 month ago

ycwsilent commented 1 month ago

在运行demo时候,加载5k的权重,但是是运行不起来, 运行命令为

python demo.py --input_dir ../datasets/FiveK/test/low --result_dir ./visual/FiveK/B1 --weights ../checkpoints/5k/W
aveNet_B_5k.pth

报错为如下;感觉就是问题2一样

RuntimeError: Error(s) in loading state_dict for WaveNet:
        Missing key(s) in state_dict: "asff.fcs.0.0.weight", "asff.fcs.0.1.weight", "asff.fcs.1.0.weight", "asff.fcs.1.1.weight", "asff.conv.weight".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "demo.py", line 252, in <module>
    load_checkpoint(model, args.weights, device)
  File "demo.py", line 226, in load_checkpoint
    state_dict = checkpoint["state_dict"]
KeyError: 'state_dict'

是有什么地方不对吗

DeniJsonC commented 1 month ago

在运行demo时候,加载5k的权重,但是是运行不起来, 运行命令为

python demo.py --input_dir ../datasets/FiveK/test/low --result_dir ./visual/FiveK/B1 --weights ../checkpoints/5k/W
aveNet_B_5k.pth

报错为如下;感觉就是问题2一样

RuntimeError: Error(s) in loading state_dict for WaveNet:
        Missing key(s) in state_dict: "asff.fcs.0.0.weight", "asff.fcs.0.1.weight", "asff.fcs.1.0.weight", "asff.fcs.1.1.weight", "asff.conv.weight".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "demo.py", line 252, in <module>
    load_checkpoint(model, args.weights, device)
  File "demo.py", line 226, in load_checkpoint
    state_dict = checkpoint["state_dict"]
KeyError: 'state_dict'

是有什么地方不对吗

你好,加载WaveNet_B_5k权重,需在WaveNet_B模型参数里设置use_asff:False.

ycwsilent commented 1 month ago

您好,感谢您的回复;好像和问题9一样,但是我修改之后,它会报错什么尺寸不一样 修改 image

运行

python demo.py --input_dir ../datasets/FiveK/test/low --result_dir ./visual/FiveK/B1 --weights ../checkpoints/5k/W
aveNet_B_5k.pth

报错

D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py:235: UserWarning: Overwriting WaveNet_T in registry with models.archs.WaveNet_arch.WaveNet_T. This is
 because the name being registered conflicts with an existing name. Please check if this is not expected.
  def WaveNet_T(pretrained=False, **kwargs):
D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py:249: UserWarning: Overwriting WaveNet_S in registry with models.archs.WaveNet_arch.WaveNet_S. This is
 because the name being registered conflicts with an existing name. Please check if this is not expected.
  def WaveNet_S(pretrained=False, **kwargs):
D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py:263: UserWarning: Overwriting WaveNet_B in registry with models.archs.WaveNet_arch.WaveNet_B. This is
 because the name being registered conflicts with an existing name. Please check if this is not expected.
  def WaveNet_B(pretrained=False, **kwargs):
==> Build the model
enhancing images......
Traceback (most recent call last):
  File "demo.py", line 272, in <module>
    retored = model(restored.cuda())
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py", line 225, in forward
    embed_x = self.forward_tokens(conv_1x)
  File "D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py", line 216, in forward_tokens
    x= block(x,enc_maps[i])
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py", line 148, in forward
    x=self.up(x)+y
RuntimeError: The size of tensor a (764) must match the size of tensor b (765) at non-singleton dimension 3

这个有办法解决吗

DeniJsonC commented 1 month ago

您好,感谢您的回复;好像和问题9一样,但是我修改之后,它会报错什么尺寸不一样 修改 image

运行

python demo.py --input_dir ../datasets/FiveK/test/low --result_dir ./visual/FiveK/B1 --weights ../checkpoints/5k/W
aveNet_B_5k.pth

报错

D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py:235: UserWarning: Overwriting WaveNet_T in registry with models.archs.WaveNet_arch.WaveNet_T. This is
 because the name being registered conflicts with an existing name. Please check if this is not expected.
  def WaveNet_T(pretrained=False, **kwargs):
D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py:249: UserWarning: Overwriting WaveNet_S in registry with models.archs.WaveNet_arch.WaveNet_S. This is
 because the name being registered conflicts with an existing name. Please check if this is not expected.
  def WaveNet_S(pretrained=False, **kwargs):
D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py:263: UserWarning: Overwriting WaveNet_B in registry with models.archs.WaveNet_arch.WaveNet_B. This is
 because the name being registered conflicts with an existing name. Please check if this is not expected.
  def WaveNet_B(pretrained=False, **kwargs):
==> Build the model
enhancing images......
Traceback (most recent call last):
  File "demo.py", line 272, in <module>
    retored = model(restored.cuda())
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py", line 225, in forward
    embed_x = self.forward_tokens(conv_1x)
  File "D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py", line 216, in forward_tokens
    x= block(x,enc_maps[i])
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\yan\WaveNet-1\basicsr\models\archs\WaveNet_arch.py", line 148, in forward
    x=self.up(x)+y
RuntimeError: The size of tensor a (764) must match the size of tensor b (765) at non-singleton dimension 3

这个有办法解决吗

这是因为上下采样造成的大小不一致,你在demo.py文件里 取消注释 102 和113行,并注释掉114行即可。

ycwsilent commented 1 month ago

好的;可以了,相当感谢作者耐心的回复;;我还有一个不太恰当的问题,我用单张3090和你yml一样的设置,在训练lol这个数据集时候和你25.4左右的结果差很大,我只有22.8左右,这个应该是我哪里操作有问题吗? 下面这个是配置文件

# general settings
name: WaveNet_B_LOL
model_type: ImageCleanModel
scale: 1
num_gpu: 1  # set num_gpu: 0 for cpu mode
manual_seed: 5

# dataset and data loader settings
#### datasets
datasets:
  train:
    name: TrainSet
    type: Dataset_PairedImage
    dataroot_gt: /data/coding/WaveNet/datasets/LOL/train/high/
    dataroot_lq: /data/coding/WaveNet/datasets/LOL/train/low
    geometric_augs: true

    filename_tmpl: '{}'
    io_backend:
      type: disk

    # data loader
    use_shuffle: true
    num_worker_per_gpu: 8
    batch_size_per_gpu: 8

    GT_size: 256     # size you want to crop out as input sample.
    LQ_size: 256
    use_flip: false
    use_rot: false
    color: RGB

    ### -------------Multi-scale Training Strategy--------------------------
    batch_sizes: [1,1,1,2]             # Batch size per gpu   
    min_patch_size: 192
    step: 3
    sort: 0 #1 represents descending and 0 represents ascending
    stride: 32
    patience: 19
    state: 1 # 0 means start with crop 1 means start with resize
    ### ------------------------------------------------------------

    dataset_enlarge_ratio: 1
    prefetch_mode: ~

  val:
    name: ValSet
    type: Dataset_PairedImage
    dataroot_gt: /data/coding/WaveNet/datasets/LOL/test/high/
    dataroot_lq: /data/coding/WaveNet/datasets/LOL/test/low/
    io_backend:
      type: disk
    val_crop: 

# network structures
network_g:
  type: WaveNet_B

# path
path:
  pretrain_network_g: ~
  strict_load_g: true
  resume_state: ~

# training settings
train:
  total_epochs: 1000
  total_iter: 145000
  warmup_iter: -1 # no warm up
  use_grad_clip: true

  # Split 300k iterations into two cycles. 
  # 1st cycle: fixed 3e-4 LR for 92k iters. 
  # 2nd cycle: cosine annealing (3e-4 to 1e-6) for 208k iters.
  scheduler:
    type: CosineAnnealingRestartCyclicLR
    periods: [450, 550,1500]       
    restart_weights: [1,1]
    eta_mins: [0.000125,0.000001,0.000001]   

  mixing_augs:
    mixup: true
    mixup_beta: 1.2
    use_identity: true

  optim_g:
    type: AdamW
    lr: !!float 1.25e-4
    # weight_decay: !!float 1e-4
    betas: [0.9, 0.999]

  # losses
  pixel_opt:
    type: ULoss
    loss_weight: 1
    reduction: mean

# validation settings
val:
  window_size: 4
  val_freq: !!float 1e2
  save_img: false
  rgb2bgr: true
  use_image: false
  max_minibatch: 8
  val_crop:

  metrics:
    psnr: # metric name, can be arbitrary
      type: calculate_psnr
      crop_border: 0
      test_y_channel: false
    ssim:
      type: calculate_ssim
      crop_border: 0
      test_y_channel: false

# logging settings
logger:
  print_freq: 100
  save_checkpoint_freq: !!float 1e2
  use_tb_logger: true
  wandb:
    project: ~
    resume_id: ~

# dist training settings
dist_params:
  backend: nccl
  port: 29500

这个是我最终的结果 image 相应的结果趋势图 image

您的训练日志 image

它不单长得不一样,而且甚至图的个数不一样,请问一下,这个应该也是我什么地方操作有问题吧 特别感谢并期待您的回答

DeniJsonC commented 1 month ago

好的;可以了,相当感谢作者耐心的回复;;我还有一个不太恰当的问题,我用单张3090和你yml一样的设置,在训练lol这个数据集时候和你25.4左右的结果差很大,我只有22.8左右,这个应该是我哪里操作有问题吗? 下面这个是配置文件

# general settings
name: WaveNet_B_LOL
model_type: ImageCleanModel
scale: 1
num_gpu: 1  # set num_gpu: 0 for cpu mode
manual_seed: 5

# dataset and data loader settings
#### datasets
datasets:
  train:
    name: TrainSet
    type: Dataset_PairedImage
    dataroot_gt: /data/coding/WaveNet/datasets/LOL/train/high/
    dataroot_lq: /data/coding/WaveNet/datasets/LOL/train/low
    geometric_augs: true

    filename_tmpl: '{}'
    io_backend:
      type: disk

    # data loader
    use_shuffle: true
    num_worker_per_gpu: 8
    batch_size_per_gpu: 8

    GT_size: 256     # size you want to crop out as input sample.
    LQ_size: 256
    use_flip: false
    use_rot: false
    color: RGB

    ### -------------Multi-scale Training Strategy--------------------------
    batch_sizes: [1,1,1,2]             # Batch size per gpu   
    min_patch_size: 192
    step: 3
    sort: 0 #1 represents descending and 0 represents ascending
    stride: 32
    patience: 19
    state: 1 # 0 means start with crop 1 means start with resize
    ### ------------------------------------------------------------

    dataset_enlarge_ratio: 1
    prefetch_mode: ~

  val:
    name: ValSet
    type: Dataset_PairedImage
    dataroot_gt: /data/coding/WaveNet/datasets/LOL/test/high/
    dataroot_lq: /data/coding/WaveNet/datasets/LOL/test/low/
    io_backend:
      type: disk
    val_crop: 

# network structures
network_g:
  type: WaveNet_B

# path
path:
  pretrain_network_g: ~
  strict_load_g: true
  resume_state: ~

# training settings
train:
  total_epochs: 1000
  total_iter: 145000
  warmup_iter: -1 # no warm up
  use_grad_clip: true

  # Split 300k iterations into two cycles. 
  # 1st cycle: fixed 3e-4 LR for 92k iters. 
  # 2nd cycle: cosine annealing (3e-4 to 1e-6) for 208k iters.
  scheduler:
    type: CosineAnnealingRestartCyclicLR
    periods: [450, 550,1500]       
    restart_weights: [1,1]
    eta_mins: [0.000125,0.000001,0.000001]   

  mixing_augs:
    mixup: true
    mixup_beta: 1.2
    use_identity: true

  optim_g:
    type: AdamW
    lr: !!float 1.25e-4
    # weight_decay: !!float 1e-4
    betas: [0.9, 0.999]

  # losses
  pixel_opt:
    type: ULoss
    loss_weight: 1
    reduction: mean

# validation settings
val:
  window_size: 4
  val_freq: !!float 1e2
  save_img: false
  rgb2bgr: true
  use_image: false
  max_minibatch: 8
  val_crop:

  metrics:
    psnr: # metric name, can be arbitrary
      type: calculate_psnr
      crop_border: 0
      test_y_channel: false
    ssim:
      type: calculate_ssim
      crop_border: 0
      test_y_channel: false

# logging settings
logger:
  print_freq: 100
  save_checkpoint_freq: !!float 1e2
  use_tb_logger: true
  wandb:
    project: ~
    resume_id: ~

# dist training settings
dist_params:
  backend: nccl
  port: 29500

这个是我最终的结果 image 相应的结果趋势图 image

您的训练日志 image

它不单长得不一样,而且甚至图的个数不一样,请问一下,这个应该也是我什么地方操作有问题吧 特别感谢并期待您的回答

你好,当时训练WaveNet的时候用的我另外一个repo:LPF的train.py文件,后面这个repo为了统一到BasicSR代码下,才修改的。你可以按照LPF下的train.py文件训练一下,配置文件也可以参考LPF/config下的配置文件设置。batch_size可以设置到占满gpu memory。原始设置如图 截屏2024-07-17 22 17 11 学习率任然是1.25*10-4。

ycwsilent commented 1 month ago

特别感谢,我用LPF下的train.py的话,应该是需要修改什么的吧,它报错说没有utils,就是LPF下的utils文件夹,那我应该移动过来吧,同样的,刚刚你说到LPF/config下的文件配置,是能不能直接修改到现有的WaveNet_B_LOL.yml里面吗?不然感觉操作起来很复杂

DeniJsonC commented 1 month ago

特别感谢,我用LPF下的train.py的话,应该是需要修改什么的吧,它报错说没有utils,就是LPF下的utils文件夹,那我应该移动过来吧,同样的,刚刚你说到LPF/config下的文件配置,是能不能直接修改到现有的WaveNet_B_LOL.yml里面吗?不然感觉操作起来很复杂

最简单的方法你直接复制WaveNet_arch.py里面的代码 到新建 LPF/model/WaveNet.py 然后导入包的路径将“from models.archs.arch_util import LayerNorm,Mlp”改为 “from model.utils import LayerNorm,Mlp” 即可。yaml文件新建一个 复制LPF的就行,然后修改上述的参数,和学习率就行了。

DeniJsonC commented 1 month ago

特别感谢,我用LPF下的train.py的话,应该是需要修改什么的吧,它报错说没有utils,就是LPF下的utils文件夹,那我应该移动过来吧,同样的,刚刚你说到LPF/config下的文件配置,是能不能直接修改到现有的WaveNet_B_LOL.yml里面吗?不然感觉操作起来很复杂

最简单的方法你直接复制WaveNet_arch.py里面的代码 到新建 LPF/model/WaveNet.py 然后导入包的路径将“from models.archs.arch_util import LayerNorm,Mlp”改为 “from model.utils import LayerNorm,Mlp” 即可。yaml文件新建一个 复制LPF的就行,然后修改上述的参数,和学习率就行了。

当然你是需要clone LPF repo 在LPF文件目录下运行 “python train.py” 修改train.py里面的加载模型 和加载配置文件的代码(18、30、58行代码),如果直接把train.py文件搬运到WaveNet repo下是无法运行的 涉及到很多文件的更改。所以建议你用上述方法来运行。

ycwsilent commented 1 month ago

特别感谢,我用LPF下的train.py的话,应该是需要修改什么的吧,它报错说没有utils,就是LPF下的utils文件夹,那我应该移动过来吧,同样的,刚刚你说到LPF/config下的文件配置,是能不能直接修改到现有的WaveNet_B_LOL.yml里面吗?不然感觉操作起来很复杂

最简单的方法你直接复制WaveNet_arch.py里面的代码 到新建 LPF/model/WaveNet.py 然后导入包的路径将“from models.archs.arch_util import LayerNorm,Mlp”改为 “from model.utils import LayerNorm,Mlp” 即可。yaml文件新建一个 复制LPF的就行,然后修改上述的参数,和学习率就行了。

当然你是需要clone LPF repo 在LPF文件目录下运行 “python train.py” 修改train.py里面的加载模型 和加载配置文件的代码(18、30、58行代码),如果直接把train.py文件搬运到WaveNet repo下是无法运行的 涉及到很多文件的更改。所以建议你用上述方法来运行。

就是需要换一个仓库,然后再来将wave模型换到LPF里面吧,好的十分感谢,真的太谢谢了;在复现的道路上真的艰难,特别感谢

ycwsilent commented 1 month ago

很抱歉,这么晚还打扰你,运行报错,你们当时是自己写了dataset类吗

(torch) root@cuxrpufetckupgim-snow-8657547bf9-47xwb:/data/coding/LPF# python train.py
Traceback (most recent call last):
  File "train.py", line 16, in <module>
    from dataset import DataLoaderTrain, DataLoaderVal
ImportError: cannot import name 'DataLoaderTrain' from 'dataset' (/data/miniconda/envs/torch/lib/python3.8/site-packages/dataset/__init__.py)
DeniJsonC commented 1 month ago

很抱歉,这么晚还打扰你,运行报错,你们当时是自己写了dataset类吗

(torch) root@cuxrpufetckupgim-snow-8657547bf9-47xwb:/data/coding/LPF# python train.py
Traceback (most recent call last):
  File "train.py", line 16, in <module>
    from dataset import DataLoaderTrain, DataLoaderVal
ImportError: cannot import name 'DataLoaderTrain' from 'dataset' (/data/miniconda/envs/torch/lib/python3.8/site-packages/dataset/__init__.py)

抱歉,dataset文件遗漏上传了,已经在LPF repo上传LPF/dataset.py文件。

ycwsilent commented 1 month ago

很抱歉,这么晚还打扰你,运行报错,你们当时是自己写了dataset类吗

(torch) root@cuxrpufetckupgim-snow-8657547bf9-47xwb:/data/coding/LPF# python train.py
Traceback (most recent call last):
  File "train.py", line 16, in <module>
    from dataset import DataLoaderTrain, DataLoaderVal
ImportError: cannot import name 'DataLoaderTrain' from 'dataset' (/data/miniconda/envs/torch/lib/python3.8/site-packages/dataset/__init__.py)

抱歉,dataset文件遗漏上传了,已经在LPF repo上传LPF/dataset.py文件。

好的,谢谢,很晚还打扰你们,谢谢

ycwsilent commented 1 month ago

在模型加载时候是不是还需要其他操作,比如传参到模型中呢?

(torch) root@uvcgrowilrtdjnaj-snow-6b96db7fbf-lrdgm:/data/coding/LPF# python train.py
==> Build the model
Traceback (most recent call last):
  File "train.py", line 61, in <module>
    model_restored=WaveNet()
TypeError: __init__() missing 2 required positional arguments: 'encode_layers' and 'decode_layers'

特别感谢,我用LPF下的train.py的话,应该是需要修改什么的吧,它报错说没有utils,就是LPF下的utils文件夹,那我应该移动过来吧,同样的,刚刚你说到LPF/config下的文件配置,是能不能直接修改到现有的WaveNet_B_LOL.yml里面吗?不然感觉操作起来很复杂

最简单的方法你直接复制WaveNet_arch.py里面的代码 到新建 LPF/model/WaveNet.py 然后导入包的路径将“from models.archs.arch_util import LayerNorm,Mlp”改为 “from model.utils import LayerNorm,Mlp” 即可。yaml文件新建一个 复制LPF的就行,然后修改上述的参数,和学习率就行了。

当然你是需要clone LPF repo 在LPF文件目录下运行 “python train.py” 修改train.py里面的加载模型 和加载配置文件的代码(18、30、58行代码),如果直接把train.py文件搬运到WaveNet repo下是无法运行的 涉及到很多文件的更改。所以建议你用上述方法来运行。

DeniJsonC commented 1 month ago

在模型加载时候是不是还需要其他操作,比如传参到模型中呢?

(torch) root@uvcgrowilrtdjnaj-snow-6b96db7fbf-lrdgm:/data/coding/LPF# python train.py
==> Build the model
Traceback (most recent call last):
  File "train.py", line 61, in <module>
    model_restored=WaveNet()
TypeError: __init__() missing 2 required positional arguments: 'encode_layers' and 'decode_layers'

特别感谢,我用LPF下的train.py的话,应该是需要修改什么的吧,它报错说没有utils,就是LPF下的utils文件夹,那我应该移动过来吧,同样的,刚刚你说到LPF/config下的文件配置,是能不能直接修改到现有的WaveNet_B_LOL.yml里面吗?不然感觉操作起来很复杂

最简单的方法你直接复制WaveNet_arch.py里面的代码 到新建 LPF/model/WaveNet.py 然后导入包的路径将“from models.archs.arch_util import LayerNorm,Mlp”改为 “from model.utils import LayerNorm,Mlp” 即可。yaml文件新建一个 复制LPF的就行,然后修改上述的参数,和学习率就行了。

当然你是需要clone LPF repo 在LPF文件目录下运行 “python train.py” 修改train.py里面的加载模型 和加载配置文件的代码(18、30、58行代码),如果直接把train.py文件搬运到WaveNet repo下是无法运行的 涉及到很多文件的更改。所以建议你用上述方法来运行。

直接调用具体的model_restored=WaveNet_B(),import 也直接是from model.WaveNet import WaveNet_T, WaveNet_S, WaveNet_B

ycwsilent commented 1 month ago

1.好的,这个LOL训练问题,终于在您的帮助下运行成功了: image 但是它可能并没有自动占满gpu;还是说它自己已经占得很大了 image

2.对于5k数据集,我用demo.py得到了增强后的图片;但是在计算指标值时候报错 输入图像尺寸不一样,后面我去看了对应的数据,确实图片尺寸不一样,请问一下,您有遇到过吗,如何处理呢 image image

Traceback (most recent call last):
  File "evaluation.py", line 134, in <module>
    measure_dirs(dirA, dirB, use_gpu=use_gpu, verbose=True)
  File "evaluation.py", line 107, in measure_dirs
    result['psnr'], result['ssim'], result['lpips'] = measure.measure(imread(pathA), imread(pathB))
  File "evaluation.py", line 32, in measure
    return [float(f(imgA, imgB)) for f in [self.psnr, self.ssim, self.lpips]]
  File "evaluation.py", line 32, in <listcomp>
    return [float(f(imgA, imgB)) for f in [self.psnr, self.ssim, self.lpips]]
  File "evaluation.py", line 49, in psnr
    psnr_val = psnr(imgA, imgB, data_range=255)
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\skimage\metrics\simple_metrics.py", line 142, in peak_signal_noise_ratio
    check_shape_equality(image_true, image_test)
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\skimage\_shared\utils.py", line 569, in check_shape_equality
    raise ValueError('Input images must have the same dimensions.')
ValueError: Input images must have the same dimensions.
DeniJsonC commented 1 month ago

1.好的,这个LOL训练问题,终于在您的帮助下运行成功了: image 但是它可能并没有自动占满gpu;还是说它自己已经占得很大了 image

2.对于5k数据集,我用demo.py得到了增强后的图片;但是在计算指标值时候报错 输入图像尺寸不一样,后面我去看了对应的数据,确实图片尺寸不一样,请问一下,您有遇到过吗,如何处理呢 image image

Traceback (most recent call last):
  File "evaluation.py", line 134, in <module>
    measure_dirs(dirA, dirB, use_gpu=use_gpu, verbose=True)
  File "evaluation.py", line 107, in measure_dirs
    result['psnr'], result['ssim'], result['lpips'] = measure.measure(imread(pathA), imread(pathB))
  File "evaluation.py", line 32, in measure
    return [float(f(imgA, imgB)) for f in [self.psnr, self.ssim, self.lpips]]
  File "evaluation.py", line 32, in <listcomp>
    return [float(f(imgA, imgB)) for f in [self.psnr, self.ssim, self.lpips]]
  File "evaluation.py", line 49, in psnr
    psnr_val = psnr(imgA, imgB, data_range=255)
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\skimage\metrics\simple_metrics.py", line 142, in peak_signal_noise_ratio
    check_shape_equality(image_true, image_test)
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\skimage\_shared\utils.py", line 569, in check_shape_equality
    raise ValueError('Input images must have the same dimensions.')
ValueError: Input images must have the same dimensions.

你需要注释掉 demo.py的114行。

ycwsilent commented 1 month ago

1.好的,这个LOL训练问题,终于在您的帮助下运行成功了: image 但是它可能并没有自动占满gpu;还是说它自己已经占得很大了 image 2.对于5k数据集,我用demo.py得到了增强后的图片;但是在计算指标值时候报错 输入图像尺寸不一样,后面我去看了对应的数据,确实图片尺寸不一样,请问一下,您有遇到过吗,如何处理呢 image image

Traceback (most recent call last):
  File "evaluation.py", line 134, in <module>
    measure_dirs(dirA, dirB, use_gpu=use_gpu, verbose=True)
  File "evaluation.py", line 107, in measure_dirs
    result['psnr'], result['ssim'], result['lpips'] = measure.measure(imread(pathA), imread(pathB))
  File "evaluation.py", line 32, in measure
    return [float(f(imgA, imgB)) for f in [self.psnr, self.ssim, self.lpips]]
  File "evaluation.py", line 32, in <listcomp>
    return [float(f(imgA, imgB)) for f in [self.psnr, self.ssim, self.lpips]]
  File "evaluation.py", line 49, in psnr
    psnr_val = psnr(imgA, imgB, data_range=255)
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\skimage\metrics\simple_metrics.py", line 142, in peak_signal_noise_ratio
    check_shape_equality(image_true, image_test)
  File "D:\Ananconda\envs\Retinexformer\lib\site-packages\skimage\_shared\utils.py", line 569, in check_shape_equality
    raise ValueError('Input images must have the same dimensions.')
ValueError: Input images must have the same dimensions.

你需要注释掉 demo.py的114行。

这个在上面你好像回答过我;不好意思,又网络,谢谢您