ChrisChen1023 / HINT

HINT: High-quality INpainting Transformer with Enhanced Attention and Mask-aware Encoding
MIT License
28 stars 3 forks source link

Question about testing #22

Open liyang0822 opened 1 month ago

liyang0822 commented 1 month ago

Thanks for your fantastic work. However, when I ran the testing procedure as you presented, there was a problem. The Traceback log is as follows: Traceback (most recent call last): File "D:\HINT\test.py", line 2, in <module> main(mode=2) File "D:\HINT\main.py", line 62, in main model.test() File "D:\HINT\src\HINT.py", line 202, in test for items in test_loader: File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\dataloader.py", line 634, in __next__ data = self._next_data() File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\dataloader.py", line 678, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\HINT\src\dataset.py", line 39, in __getitem__ item = self.load_item(index) File "D:\HINT\src\dataset.py", line 59, in load_item mask = self.load_mask(img, index) File "D:\HINT\src\dataset.py", line 125, in load_mask mask = rgb2gray(mask) File "D:\Anaconda\envs\inp\lib\site-packages\skimage\_shared\utils.py", line 438, in fixed_func return func(*args, **kwargs) File "D:\Anaconda\envs\inp\lib\site-packages\skimage\color\colorconv.py", line 982, in rgb2gray rgb = _prepare_colorarray(rgb) File "D:\Anaconda\envs\inp\lib\site-packages\skimage\color\colorconv.py", line 170, in _prepare_colorarray raise ValueError(msg) ValueError: the input array must have size 3 alongchannel_axis, got (256, 256)

The mask files are single-channel. However, line 125 mask = rgb2gray(mask) in dataset.py needs three channels. Am I missing something when loading mask files? Looking forward to your reply, thanks.

ChrisChen1023 commented 1 month ago

Thanks for your fantastic work. However, when I ran the testing procedure as you presented, there was a problem. The Traceback log is as follows: Traceback (most recent call last): File "D:\HINT\test.py", line 2, in <module> main(mode=2) File "D:\HINT\main.py", line 62, in main model.test() File "D:\HINT\src\HINT.py", line 202, in test for items in test_loader: File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\dataloader.py", line 634, in __next__ data = self._next_data() File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\dataloader.py", line 678, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\Anaconda\envs\inp\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\HINT\src\dataset.py", line 39, in __getitem__ item = self.load_item(index) File "D:\HINT\src\dataset.py", line 59, in load_item mask = self.load_mask(img, index) File "D:\HINT\src\dataset.py", line 125, in load_mask mask = rgb2gray(mask) File "D:\Anaconda\envs\inp\lib\site-packages\skimage\_shared\utils.py", line 438, in fixed_func return func(*args, **kwargs) File "D:\Anaconda\envs\inp\lib\site-packages\skimage\color\colorconv.py", line 982, in rgb2gray rgb = _prepare_colorarray(rgb) File "D:\Anaconda\envs\inp\lib\site-packages\skimage\color\colorconv.py", line 170, in _prepare_colorarray raise ValueError(msg) ValueError: the input array must have size 3 alongchannel_axis, got (256, 256)

The mask files are single-channel. However, line 125 mask = rgb2gray(mask) in dataset.py needs three channels. Am I missing something when loading mask files? Looking forward to your reply, thanks.

Hi liyang,

In this case, your mask is already gray scale i believe, just comment the line 125, it should be working.

Let me know if you need other help.

Best,

Chris

liyang0822 commented 1 month ago

Thank you for your prompt reply! After commenting the line 125, the following error arises:

Traceback (most recent call last):
  File "D:\HINT\main.py", line 62, in main
    model.test()
  File "D:\HINT\src\HINT.py", line 218, in test
    psnr, ssim = self.metric(images, outputs_merged)
  File "D:\HINT\src\HINT.py", line 307, in metric
    ssim = compare_ssim(gt, pre, multichannel=True, data_range=255)
  File "D:\Anaconda\envs\inp\lib\site-packages\skimage\metrics\_structural_similarity.py", line 186, in structural_similarity
    raise ValueError(
ValueError: win_size exceeds image extent. Either ensure that your images are at least 7x7; or pass win_size explicitly in the function call, with an odd value less than or equal to the smaller side of your images. If your images are multichannel (with color channels), set channel_axis to the axis number corresponding to the channels.

There is an error when calculating the SSIM metric. The Dunhuang dataset is used for testing. I'm wondering whether the current testing code is not suitable for the Dunhuang dataset and needs to be adjusted. If so, could you advise which parts need to be adjusted if you have the time? Thanks!