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

VOC2007 train #8

Open
wulele2 opened this issue Jun 23, 2020 · 20 comments
Open

VOC2007 train #8

wulele2 opened this issue Jun 23, 2020 · 20 comments

Comments

@wulele2
Copy link

wulele2 commented Jun 23, 2020

Hi, I used your code training on the voc2007 train data which contains 5k images, and then run your demo finding the results is very bad. Could it be the lack of data sets that causes this failure? After all, I have a few computing resources.

@VectXmy
Copy link
Owner

VectXmy commented Jun 23, 2020

sorry,the preprocessing of demo.py is for pre-trained model converted from official repo. You should uncomment some code in demo.py.

@wulele2
Copy link
Author

wulele2 commented Jun 23, 2020

Yes, I have modified the demo.py to fit the VOC data set. Do you think it might be the lack of training sets?

@VectXmy
Copy link
Owner

VectXmy commented Jun 23, 2020

You didn't provide any information. I couldn't help you. Training curve, demo output or something else.

@wulele2
Copy link
Author

wulele2 commented Jun 23, 2020

Thank you for your reply. Now there are often problems with the remote connection of our school's server. Many of the results don't show up. I'm looking into it. Thank you very much. I'll discuss it with you when I have a good result.

@zhenghao977
Copy link

Thank you for your reply. Now there are often problems with the remote connection of our school's server. Many of the results don't show up. I'm looking into it. Thank you very much. I'll discuss it with you when I have a good result.

You can refer to https://github.com/ChingHo97/FCOS-PyTorch-37.2AP I have fixed some bugs

@VectXmy
Copy link
Owner

VectXmy commented Jun 28, 2020

Thank you for your reply. Now there are often problems with the remote connection of our school's server. Many of the results don't show up. I'm looking into it. Thank you very much. I'll discuss it with you when I have a good result.

You can refer to https://github.com/ChingHo97/FCOS-PyTorch-37.2AP I have fixed some bugs

Thanks for your work! Do you mind I add a link to your work into my README ? and I also would like you to indicate in README that you have referenced my code.

@zhenghao977
Copy link

zhenghao977 commented Jun 28, 2020 via email

@zhengdq99
Copy link

zhengdq99 commented Sep 21, 2020

代码里面有些问题,我很疑惑。
1.cls_loss里面没有进行正样本筛选
pred_pos = preds[batch_index][mask[batch_index]]
target_pos = target_pos[mask[batch_index]]
2.backbone里面的fc层之前的pooling是错误的,改为:self.avgpool = nn.AdaptiveAvgPool2d((1, 1)),当然目标检测没有用到
3.加载resnet预训练模型的时候,没有去掉top
if pretrained:
model_dict = model.state_dict()
pretrained_dict = torch.load("./checkpoints/resnet50-19c8e357.pth")
if not if_include_top:
pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in model_dict}
# 将pretrained_dict里不属于model_dict的键剔除掉
# 以上作者错误
model.load_state_dict(pretrained_dict)
# Unexpected key(s) in state_dict: "fc.weight", "fc.bias".因为网上预训练的resnet50没有去掉全连接层。

@zhengdq99
Copy link

zhengdq99 commented Sep 21, 2020

_gen_level_targets里面这些代码没有用到
# cnt_logits = cnt_logits.permute(0, 2, 3, 1)
# cnt_logits = cnt_logits.reshape((batch_size, -1, 1))
# reg_preds = reg_preds.permute(0, 2, 3, 1)
# reg_preds = reg_preds.reshape((batch_size, -1, 4)) # 把点数放中间

@zhengdq99
Copy link

训练voc,cnt_loss不收敛,reg_loss到0.1左右也停了。
image
测试结果都是错误的
image

@VectXmy
Copy link
Owner

VectXmy commented Sep 21, 2020

@zhengdq99
创建模型时没有fc层,也就不用管池化层。在resnet中将strict参数设为False即可。_gen_level_targets中那些可以注释掉。分类不需要进行正样本筛选。
不给出训练参数无从评价。可能原因:batch size太小,学习率太大等等。centerness在batch size较小时难以收敛。

if if_include_top:
            self.fc = nn.Linear(512 * block.expansion, num_classes)

@VectXmy
Copy link
Owner

VectXmy commented Sep 21, 2020

@zhengdq99 如果没看错的话,你才训练了一个epoch不到就说不收敛,还在warm up阶段-_-|||

@zhengdq99
Copy link

训练了很多epoch,是从保存的模型中继续训练。

@zhengdq99
Copy link

@zhengdq99
创建模型时没有fc层,也就不用管池化层。在resnet中将strict参数设为False即可。_gen_level_targets中那些可以注释掉。分类不需要进行正样本筛选。
不给出训练参数无从评价。可能原因:batch size太小,学习率太大等等。centerness在batch size较小时难以收敛。

if if_include_top:
            self.fc = nn.Linear(512 * block.expansion, num_classes)

非常感谢

@zhengdq99
Copy link

zhengdq99 commented Sep 21, 2020

我最近才买了深度学习工作站,回头按照您的参数进行训练。

@VectXmy
Copy link
Owner

VectXmy commented Sep 21, 2020

@zhengdq99
您可以使用 https://github.com/ChingHo97/FCOS-PyTorch-37.2AP 这个仓库的代码,他fix了我的一些错误

@zhengdq99
Copy link

好的,谢谢大佬指点。感激不尽。

@zhengdq99
Copy link

zhengdq99 commented Sep 21, 2020

在图像尺寸方面,我感觉fcos不需要严格按照图像原有的长宽比。
用opencv直接进行相同尺寸的缩放,不会影响结果吧?而且内存占用还少。
h_img, w_img, _ = image.shape
h_in, w_in = input_ksize
scale_h = h_in / h_img
scale_w = w_in / w_img
image_resized = cv2.resize(image, (w_in, h_in))
image_paded = np.zeros(shape=[h_in, w_in, 3], dtype=np.uint8)
image_paded[:h_in, :w_in, :] = image_resized

@VectXmy
Copy link
Owner

VectXmy commented Sep 21, 2020

@zhengdq99 不可以哦,直接resize,会导致物体形状完全变了,可能把一个东西拉的很长或很扁,跟实际测试相差很大

@zhengdq99
Copy link

zhengdq99 commented Sep 21, 2020 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