ispamm / NAF-DPM

NAF-DPM: A Nonlinear Activation-Free Diffusion Probabilistic Model for Document Enhancement
MIT License
32 stars 4 forks source link

Lack of resources to replicate experiment #7

Open juampe opened 3 months ago

juampe commented 3 months ago

Hi! I hope all you are well. Thanks for this great work, I think your work is a SOAT in document enhancement and binarization I come here from https://github.com/ZZZHANG-jx/Recommendations-Document-Image-Processing I got some issues in the repo (or I'm lost and I missed many details)

Giordano-Cicchetti commented 2 months ago

Hi, and sorry for the late reply. Thank you for the question and thank you for your interest in our work.

  1. The original dataset site is https://www.fit.vut.cz/person/ihradis/public/CNN-Deblur. However, I found that the URL is no longer accessible. Since we do not have a backup of this dataset, an Internet search should be conducted to see if a backup is available.

  2. For some strange reason the pretrained model checkpoints had been deleted from the drive folder. They are now available again within their respective drive folders. Thank you for noticing this imperfection

  3. The git clone statement has been modified.

Thank you again for the issue.

juampe commented 2 months ago

Hi again, Thanks for reply. I have found a replacement URL for Hradiš Michal research and deblur resources: https://www.fit.vut.cz/research/publication/10922/ https://github.com/sandeepraju/ihradis-cnn-deblur

juampe commented 2 months ago

Hi again! I did some initial test

Deblur test needs cnn-deblur, and AFAIK is not easy to find

PS L:\Jupyter\NAF-DPM> python .\main.py --config .\deblurring.yml
Config loaded
--------------------------
Start Testing
--------------------------
Loading pretrained model LPIPS from C:\Users\juamp\.cache\torch\hub\checkpoints\LPIPS_v0.1_alex-df73285e.pth
l:\Jupyter\.conda\Lib\site-packages\pyiqa\archs\arch_util.py:108: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
  state_dict = torch.load(model_path, map_location=torch.device("cpu"))
Loading pretrained model DISTS from C:\Users\juamp\.cache\torch\hub\checkpoints\DISTS_weights-f5e65c96.pth
Loading pretrained model MUSIQ from C:\Users\juamp\.cache\torch\hub\checkpoints\musiq_koniq_ckpt-e95806b9.pth
Traceback (most recent call last):
  File "L:\Jupyter\NAF-DPM\main.py", line 63, in <module>
    main()
  File "L:\Jupyter\NAF-DPM\main.py", line 26, in main
    tester = Tester(config)
             ^^^^^^^^^^^^^^
  File "L:\Jupyter\NAF-DPM\Deblurring\src\tester.py", line 133, in __init__
    dataset_test = DocData(config.TEST_PATH_IMG, config.TEST_PATH_GT, config.IMAGE_SIZE, self.mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "L:\Jupyter\NAF-DPM\Deblurring\data\docdata.py", line 29, in __init__
    self.data_gt = sorted(os.listdir(path_gt))
                          ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 3] El sistema no puede encontrar la ruta especificada: 'L:\\Jupyter\\NAF-DPM\\Datasets\\CNNDeblur\\orig'

The checkpoint is not valid for binarizarion due to layout mismatch. maybe the checkpoint for binarization must be different?

PS L:\Jupyter\NAF-DPM> python .\main.py --config .\binarization.yml
Config loaded
--------------------------
Start Testing
--------------------------
L:\Jupyter\NAF-DPM\Binarization\src\tester.py:222: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
  checkpoint_init = torch.load(self.TEST_INITIAL_PREDICTOR_WEIGHT_PATH)
L:\Jupyter\NAF-DPM\Binarization\src\tester.py:223: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
  checkpoint_denoiser = torch.load(self.TEST_DENOISER_WEIGHT_PATH)
Traceback (most recent call last):
  File "L:\Jupyter\NAF-DPM\main.py", line 63, in <module>
    main()
  File "L:\Jupyter\NAF-DPM\main.py", line 27, in main
    tester.test()
  File "L:\Jupyter\NAF-DPM\Binarization\src\tester.py", line 224, in test
    self.network.init_predictor.load_state_dict(checkpoint_init['model_state_dict'])
  File "l:\Jupyter\.conda\Lib\site-packages\torch\nn\modules\module.py", line 2215, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for NAFNet:
        size mismatch for intro.weight: copying a param with shape torch.Size([32, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([32, 1, 3, 3]).
        size mismatch for ending.weight: copying a param with shape torch.Size([3, 32, 3, 3]) from checkpoint, the shape in current model is torch.Size([1, 32, 3, 3]).
        size mismatch for ending.bias: copying a param with shape torch.Size([3]) from checkpoint, the shape in current model is torch.Size([1]).
mingheyuemankong commented 1 month ago

Hi again, Thanks for reply. I have found a replacement URL for Hradiš Michal research and deblur resources: https://www.fit.vut.cz/research/publication/10922/ https://github.com/sandeepraju/ihradis-cnn-deblur

Hi, I still can't get that dataset through the url link you gave, can you provide more information? I would like to get the download link for that dataset.

For your convenience to communicate anytime, I am leaving my email address here: yf196369@gmail.com