Git Product home page Git Product logo

Comments (19)

courao avatar courao commented on May 20, 2024

可以贴一下详细的错误信息吗

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

我觉得应该还是trans.py对图像处理过程出了问题,可能输入的图像本身长或宽不够,造成resize后的图像长或宽小于等于了0。但是这应该如何修改呢?
debug

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

debug

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

一个简单粗暴的方法是在mydataset.py文件中把__getitem__中的代码加一个try catch,就比如用下面的代码替换一下
def __getitem__(self, index): try: img = Image.open(self.files[index]) if self.transform is not None: img = self.transform( img ) img = img.convert('L') label = self.labels[index] if self.target_transform is not None: label = self.target_transform( label ) return (img,label) except: return self.__getitem__(np.random.randint(self.__len__()))

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

emmm插入的代码不知道为啥排版不太好,重新发一下吧:
def getitem(self, index):
try:
img = Image.open(self.files[index])
if self.transform is not None:
img = self.transform( img )
img = img.convert('L')
label = self.labels[index]
if self.target_transform is not None:
label = self.target_transform( label )
return (img,label)
except:
return self.getitem(np.random.randint(self.len()))

就是在原来的基础上加一个try catch如果有异常则重新换一个

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

谢谢您的指点,不过我加入了异常处理后又出现了新的错误,您能否帮我看一下是什么原因?我还需要修改哪些地方?
debug

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

这个问题应该是在验证集上测试的时候报的错,看着似乎是模型时cpu上的 输入的图像是gpu上的造成的,你是在cpu上训练的吗?
正常在GPU上训练的话,不会出现这样的情况。。

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

不好意思,我发现config没有调回来,这应该是CPU上训练的结果,我如果在CPU上训练需要对测试的代码进行什么改动呢?我现在GPU出现了一些状况没办法输出运行结果,等拿到出错信息后我再给您看。

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

在训练代码中找到这一行num_correct, num_all = val_model(config.val_infofile,net,True,log_file='compare-'+config.saved_model_prefix+'.log'),
把True改成False

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

谢谢作者大佬,CPU上的运行已经没有问题了,但是在GPU上训练时输入某些图片还会出错,我把一张出错的图片放在下面,您能帮我看一下为什么会报错吗?
k04-061-06-05

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

从图片上看不出问题啊,报的什么错呢?异常处理也解决不了吗?

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

因为我是连服务器上运行的,一到这种图片服务器就把我kill了,而且没有错误信息,用nohup指令也没法把错误信息输出来。您能否试一下这张图片有没有什么问题?非常感谢!

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

你好,我这边暂时也没有空余的GPU服务器没法再GPU上测试,不过我在本地测试了一下这张图似乎没啥问题,我在想是不是因为路径什么的有错误,其他的我也说不上来什么原因。
我觉得至少得有点错误信息才能看看是哪个环节有问题,或者你在那个try catch的地方让它在catch之后把捕捉的错误打出来看看。

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

好的,谢谢您的帮助,我再想想办法。不过奇怪的是这张图片在CPU模型里没有问题,到了GPU就出问题了。

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

大佬您好,我让朋友帮我测试了一下,他遇到了一个奇怪的问题,但是感觉这个错误比较奇怪,如果是这种错误感觉我之前不可能跑通,为什么会遇到这种问题呢?
debug

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

顺带一问,我在CPU训练的检测部分遇到了outputsize过小的问题,这有办法解决吗?
debug

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

大佬您好,我让朋友帮我测试了一下,他遇到了一个奇怪的问题,但是感觉这个错误比较奇怪,如果是这种错误感觉我之前不可能跑通,为什么会遇到这种问题呢?
debug

应该是pytorch版本的问题,比较早的版本没有这个zero_infinity参数

from ocr.pytorch.

courao avatar courao commented on May 20, 2024

顺带一问,我在CPU训练的检测部分遇到了outputsize过小的问题,这有办法解决吗?
debug

抱歉,从图中看不出outputsize过小的问题

from ocr.pytorch.

yhl-97 avatar yhl-97 commented on May 20, 2024

作者大佬您好,我在cpu上训练时基本上不会出现错误,但是在训练到第二个epoch时速度就会变得非常慢,基本上处在停滞状态,这可能是因为什么引起的?

from ocr.pytorch.

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.