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

ValueError: invalid literal for int() with base 10: ' gen_0000' #26

Open
Meimeiainaonao opened this issue Nov 15, 2019 · 4 comments
Open

Comments

@Meimeiainaonao
Copy link

你好,感谢你的分享!有一个问题想向你请教~我已经通过DCGAN生成图像并且放到train_new中,如下图所示:
2019-11-15 16-28-21屏幕截图
生成图像的索引如下:
2019-11-15 16-40-08屏幕截图

但是在跑train_baseline的时候,却出现了下面的错误,

Traceback (most recent call last):
File "/home/meichen/SourceProject/Person-reid-GAN-pytorch-master/train_baseline.py", line 178, in
dataloaders['train'] = DataLoader(dcganDataset('train_new',data_transforms['train']), batch_size=opt.batchsize,
File "/home/meichen/SourceProject/Person-reid-GAN-pytorch-master/train_baseline.py", line 115, in init
self.img_label.append(int(folder))
ValueError: invalid literal for int() with base 10: ' gen_0000'

对应错的错误位置是dcgandata类,如下:

    if root=='train_new' :
        for folder in os.listdir(self.image_dir):
            fdir=self.image_dir+'/'+folder    # folder gen_0000 means the images are generated images, so their flags are 1
            if folder == 'gen_0000':     
                for files in os.listdir(fdir):
                    temp=folder+'_'+files
                    self.img_label.append(int(folder[-4:]))
                    self.img_flag.append(1)
                    self.samples.append(temp)
            else:
                for files in os.listdir(fdir):
                    temp=folder+'_'+files
                    self.img_label.append(int(folder))  #**提示这一行是有问题的**
                    self.img_flag.append(0)
                    self.samples.append(temp)

实在是没有想明白,跪求解答!

@qiaoguan
Copy link
Owner

抱歉,因为不做这个了,也很久不做CV方向了,我个人也很久没看了,所以这个项目就不不再维护了, 这个代码跑起来可能得你大概看懂这个代码, 但是代码肯定是能用的, 一些报错你需要尽量看懂程序是怎么执行的(主要是图片的生成后,label的处理, 还有loss function的实现),你可以按我说的尝试着看一下代码,看一下主要的代码就ok。

@Meimeiainaonao
Copy link
Author

很感谢你的答复

@Meimeiainaonao
Copy link
Author

整体代码我都看过了,很感谢的分享。让我不懂的就是这个提示错误的地方,else后面应该指的是读取非gen_0000的文件名索引,但是报错却是提醒我说gen_0000中的图片索引读不进去,让我很费解。

@Zhangzhengyi-up
Copy link

请问您的这个问题解决了吗?我遇到了相同的问题

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

3 participants