Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataset.py文件中测试函数名称不对 #3

Closed
aoxipo opened this issue Sep 5, 2018 · 12 comments
Closed

dataset.py文件中测试函数名称不对 #3

aoxipo opened this issue Sep 5, 2018 · 12 comments

Comments

@aoxipo
Copy link

aoxipo commented Sep 5, 2018

大概在142行
还有就是关于执行python main.py -a test 的时候报错
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 481 and 321 in dimension 2
后来发现运行dataset.py文件显示的测试数据集大小为(3,64,64) 训练数据集大小为(3,481,321)(ps:测试图像是我自己选的)在这里给大家说一下。。。。
解决方法是在第99行sample{‘O’:O}前一行加上
O=cv2.resize(O,(patch_size,patch_size))
就可以了

@SherlockSunset
Copy link

但是我改了还是报错NameError: name 'patch_size' is not defined,我猜应该是数据集test文件下的图片的问题,有些是321481的,有些是481321的。。。

@aoxipo
Copy link
Author

aoxipo commented Sep 5, 2018

class TestDataset(Dataset):

def __init__(self, name):
    super().__init__()
    self.rand_state = RandomState(66)
    self.root_dir = os.path.join(settings.data_dir, name)
    self.mat_files = os.listdir(self.root_dir)
    self.patch_size = settings.patch_size
    self.file_num = len(self.mat_files)

def __len__(self):
    return self.file_num

def __getitem__(self, idx):
    patch_size = self.patch_size
    file_name = self.mat_files[idx % self.file_num]
    img_file = os.path.join(self.root_dir, file_name)
    img_pair = cv2.imread(img_file).astype(np.float32) / 255
    img_pair = cv2.resize(img_pair, (patch_size, patch_size))
    O = np.transpose(img_pair, (2, 0, 1))
    
    sample = {'O': O}

    return sample

很抱歉提供了错误的修改方式,我又重新改了一次

@SherlockSunset
Copy link

刚才我自己跑的时候报错之后就把patch_size = self.patch_size了,但是还是出现了
2018-09-05 20:23:58,584 - INFO - set log dir as ../logdir
2018-09-05 20:23:58,584 - INFO - set model dir as ../models
Traceback (most recent call last):
File "main.py", line 229, in
run_test(args.model)
File "main.py", line 206, in run_test
pred, loss, losses = sess.inf_batch('test', batch)
File "main.py", line 105, in inf_batch
O, B = batch['O'], batch['B']
KeyError: 'B'
这个错,楼主你有这个情况吗

@aoxipo
Copy link
Author

aoxipo commented Sep 5, 2018

我也是刚刚运行的时候发现了这个问题,他使用的inf_batch是训练用的函数所以有O(有雨图)和B(去雨图),测试因为是测试图,所以没有B,所以这个地方报错了,我在试图更改。。。改完回复你

@XiaLiPKU
Copy link
Owner

大概在142行
还有就是关于执行python main.py -a test 的时候报错
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 481 and 321 in dimension 2
后来发现运行dataset.py文件显示的测试数据集大小为(3,64,64) 训练数据集大小为(3,481,321)(ps:测试图像是我自己选的)在这里给大家说一下。。。。
解决方法是在第99行sample{‘O’:O}前一行加上
O=cv2.resize(O,(patch_size,patch_size))
就可以了

Please replace TrainValDataset with TestDataset in main.py when you run testing.
Sorry for not refering that in README.md

@SherlockSunset
Copy link

楼主,你最终把这个论文的代码跑通了吗?我怎么总感觉有问题,看到了望尽快回复,谢谢

@aoxipo
Copy link
Author

aoxipo commented Oct 4, 2018

@SherlockSunset 我发现他的测试代码有问题,所以只跑了show.py 和train.py 最后效果出来一张测试图片有4张输出图片,可能是因为我只训练了4800多步所以实际效果并不怎么好,只去掉了大部分的雨
4800_val

@aoxipo
Copy link
Author

aoxipo commented Oct 4, 2018

大概在142行
还有就是关于执行python main.py -a test 的时候报错
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 481 and 321 in dimension 2
后来发现运行dataset.py文件显示的测试数据集大小为(3,64,64) 训练数据集大小为(3,481,321)(ps:测试图像是我自己选的)在这里给大家说一下。。。。
解决方法是在第99行sample{‘O’:O}前一行加上
O=cv2.resize(O,(patch_size,patch_size))
就可以了

Please replace TrainValDataset with TestDataset in main.py when you run testing.
Sorry for not refering that in README.md

think you

@KCHENPENGFEI
Copy link

@SherlockSunset 我发现他的测试代码有问题,所以只跑了show.py 和train.py 最后效果出来一张测试图片有4张输出图片,可能是因为我只训练了4800多步所以实际效果并不怎么好,只去掉了大部分的雨
4800_val

为什么我跑不了4800步,这个步数不是和训练图片多少有关的么?700张图片我只能跑600多步

@XiaLiPKU
Copy link
Owner

@SherlockSunset 我发现他的测试代码有问题,所以只跑了show.py 和train.py 最后效果出来一张测试图片有4张输出图片,可能是因为我只训练了4800多步所以实际效果并不怎么好,只去掉了大部分的雨
4800_val

为什么我跑不了4800步,这个步数不是和训练图片多少有关的么?700张图片我只能跑600多步

This problem lies on the usage of iter, and I have fixed all the problems.
Please refer the newest commit.
Hope it can help you!

@XiaLiPKU
Copy link
Owner

pred, loss, losses = sess.inf_batch('test', batch)
File "main.py", line 105, in inf_batch
O, B = batch['O'], batch['B']
KeyError: 'B'
这个错,楼主你有这个情况吗

I fix this problem today, please refer to the latest commit

@KCHENPENGFEI
Copy link

KCHENPENGFEI commented Oct 26, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants