Code Monkey home page Code Monkey logo

Comments (12)

aoxipo avatar aoxipo commented on August 17, 2024 2

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

from rescan.

SherlockSunset avatar SherlockSunset commented on August 17, 2024 1

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

from rescan.

XiaLiPKU avatar XiaLiPKU commented on August 17, 2024 1

大概在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

from rescan.

aoxipo avatar aoxipo commented on August 17, 2024

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

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

from rescan.

SherlockSunset avatar SherlockSunset commented on August 17, 2024

刚才我自己跑的时候报错之后就把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'
这个错,楼主你有这个情况吗

from rescan.

SherlockSunset avatar SherlockSunset commented on August 17, 2024

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

from rescan.

aoxipo avatar aoxipo commented on August 17, 2024

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

from rescan.

aoxipo avatar aoxipo commented on August 17, 2024

大概在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

from rescan.

KCHENPENGFEI avatar KCHENPENGFEI commented on August 17, 2024

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

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

from rescan.

XiaLiPKU avatar XiaLiPKU commented on August 17, 2024

@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!

from rescan.

XiaLiPKU avatar XiaLiPKU commented on August 17, 2024

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

from rescan.

KCHENPENGFEI avatar KCHENPENGFEI commented on August 17, 2024

from rescan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.