daybreak-u / thundernet_pytorch Goto Github PK
View Code? Open in Web Editor NEWImplementation Thundernet
Implementation Thundernet
I want to use PSROIAlign in my project which is based on pytorch0.4, could you please tell me where I can find the matched Pytorch version of PSROIAlign?
大神,我看你的代码中CEM模块只有卷积层,没有BN层和RELU层。请问是否需要添加BN和RELU层呢?yolo v3上采用前的1*1模块有BN和LEAKRELU。如下:
`[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky
[upsample]
stride=2`
Hi,
我想问下,是不是需要预训练文件的放入?
当我运行sh. train_146.sh 的时候
作者有没有训练好的预训练模型,方便分享一下snet146/snet_146/pascal_voc7012/thundernet_epoch_2.pth
请问你是怎么解决这个问题的呀?
Originally posted by @Lilin-Xu in #22 (comment)
Hi Ouyang,
Great work! Now I've finished the training on Pascal VOC and begin to do the testing job. I got some questions here that 1) the snet_146 model can only run 90FPS+ on RTX2060; 2) when I test without "--cuda", errors pop up...
Any help is appreciated!
Shun
您好,我尝试使用您的代码。
我在第一次运行的时候遇到了#22 issue同样的问题。
weights/ 提供的sn146的预训练模型好像损坏了,无法解压提取。
所以我在跑的时候,去掉了参数--r。
但是跑VOC,AP和Results都很低,只有38多点
预测的结果
请问您出现过这种情况吗?为什么会这样?谢谢!
Hi,
I cannot seem to be able to extract the pretrained weights file in the ./weights
directory titled "snet146.tar" . It seems corrupted. Can you please re-upload it?
Thanks
你好,请问你有试过,将thundernet部署到x86平台嘛? 有试过将thundernet转onnx之后的模型部署嘛
你好,非常感谢你的工作,我在build psroialign模块之后跑不通,提示cudaCheckError() failed : invalid device function,在setup.py中新增了"nvcc":['-arch=sm_61'],但还是没有解决,请问你有遇到这样的情况吗?
作者大大您好:
谢谢开源可以学习!!
看到您实现的shufflenet的block实现,好像和论文里面的不一样啊,这个会有影响吗?
def forward(self, old_x):
if self.stride==1:
x_proj, x = self.channel_shuffle(old_x)
return torch.cat((x_proj, self.branch_main(x)), 1)
elif self.stride==2:
x_proj = old_x
x = old_x
return torch.cat((self.branch_proj(x_proj), self.branch_main(x)), 1)
下面是我之前不知道从哪个repo搞过来的,貌似和论文是一致的 :-)
`import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from collections import OrderedDict
from torch.nn import init
import math
def conv_bn(inp, oup, stride):
return nn.Sequential(
nn.Conv2d(inp, oup, 3, stride, 1, bias=False),
nn.BatchNorm2d(oup),
nn.ReLU(inplace=True)
)
def conv_1x1_bn(inp, oup):
return nn.Sequential(
nn.Conv2d(inp, oup, 1, 1, 0, bias=False),
nn.BatchNorm2d(oup),
nn.ReLU(inplace=True)
)
def channel_shuffle(x, groups):
batchsize, num_channels, height, width = x.data.size()
channels_per_group = num_channels // groups
# reshape
x = x.view(batchsize, groups,
channels_per_group, height, width)
x = torch.transpose(x, 1, 2).contiguous()
# flatten
x = x.view(batchsize, -1, height, width)
return x
class InvertedResidual(nn.Module):
def init(self, inp, oup, stride, benchmodel):
super(InvertedResidual, self).init()
self.benchmodel = benchmodel
self.stride = stride
assert stride in [1, 2]
oup_inc = oup//2
if self.benchmodel == 1:
#assert inp == oup_inc
self.banch2 = nn.Sequential(
# pw
nn.Conv2d(oup_inc, oup_inc, 1, 1, 0, bias=False),
nn.BatchNorm2d(oup_inc),
nn.ReLU(inplace=True),
# dw
nn.Conv2d(oup_inc, oup_inc, 3, stride, 1, groups=oup_inc, bias=False),
nn.BatchNorm2d(oup_inc),
# pw-linear
nn.Conv2d(oup_inc, oup_inc, 1, 1, 0, bias=False),
nn.BatchNorm2d(oup_inc),
nn.ReLU(inplace=True),
)
else:
self.banch1 = nn.Sequential(
# dw
nn.Conv2d(inp, inp, 3, stride, 1, groups=inp, bias=False),
nn.BatchNorm2d(inp),
# pw-linear
nn.Conv2d(inp, oup_inc, 1, 1, 0, bias=False),
nn.BatchNorm2d(oup_inc),
nn.ReLU(inplace=True),
)
self.banch2 = nn.Sequential(
# pw
nn.Conv2d(inp, oup_inc, 1, 1, 0, bias=False),
nn.BatchNorm2d(oup_inc),
nn.ReLU(inplace=True),
# dw
nn.Conv2d(oup_inc, oup_inc, 3, stride, 1, groups=oup_inc, bias=False),
nn.BatchNorm2d(oup_inc),
# pw-linear
nn.Conv2d(oup_inc, oup_inc, 1, 1, 0, bias=False),
nn.BatchNorm2d(oup_inc),
nn.ReLU(inplace=True),
)
@staticmethod
def _concat(x, out):
# concatenate along channel axis
return torch.cat((x, out), 1)
def forward(self, x):
if 1==self.benchmodel:
x1 = x[:, :(x.shape[1]//2), :, :]
x2 = x[:, (x.shape[1]//2):, :, :]
out = self._concat(x1, self.banch2(x2))
elif 2==self.benchmodel:
out = self._concat(self.banch1(x), self.banch2(x))
return channel_shuffle(out, 2)
class ShuffleNetV2(nn.Module):
def init(self, n_class=1000, input_size=224, width_mult=1., back_flag = False):
super(ShuffleNetV2, self).init()
assert input_size % 32 == 0
self.stage_repeats = [4, 8, 4]
self.back_flag = back_flag
# index 0 is invalid and should never be called.
# only used for indexing convenience.
if width_mult == 0.5:
self.stage_out_channels = [-1, 24, 48, 96, 192, 1024]
elif width_mult == 1.0:
self.stage_out_channels = [-1, 24, 116, 232, 464, 1024]
elif width_mult == 1.5:
self.stage_out_channels = [-1, 24, 176, 352, 704, 1024]
elif width_mult == 2.0:
self.stage_out_channels = [-1, 24, 224, 488, 976, 2048]
else:
raise ValueError(
"""{} groups is not supported for
1x1 Grouped Convolutions""".format(num_groups))
# building first layer
input_channel = self.stage_out_channels[1]
self.conv1 = conv_bn(3, input_channel, 2)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
self.stage2 = []
self.stage3 = []
self.stage4 = []
for idxstage in range(len(self.stage_repeats)):
output_channel = self.stage_out_channels[idxstage+2]
numrepeat = self.stage_repeats[idxstage]
stage = []
for i in range(numrepeat):
if i == 0:
stage.append(InvertedResidual(input_channel, output_channel, 2, 2))
else:
stage.append(InvertedResidual(input_channel, output_channel, 1, 1))
input_channel = output_channel
if idxstage == 0:
self.stage2 = stage
elif idxstage == 1:
self.stage3 = stage
elif idxstage == 2:
self.stage4 = stage
else:
print("error")
# self.stages = nn.Sequential(*self.stages)
self.stage2 = nn.Sequential(*self.stage2) # 58 * 58 * 116
self.stage3 = nn.Sequential(*self.stage3) # 26 * 26 * 232
self.stage4 = nn.Sequential(*self.stage4)
self.features = []
# building inverted residual blocks
for idxstage in range(len(self.stage_repeats)):
numrepeat = self.stage_repeats[idxstage]
output_channel = self.stage_out_channels[idxstage+2]
for i in range(numrepeat):
if i == 0:
#inp, oup, stride, benchmodel):
self.features.append(InvertedResidual(input_channel, output_channel, 2, 2))
else:
self.features.append(InvertedResidual(input_channel, output_channel, 1, 1))
input_channel = output_channel
# make it nn.Sequential
self.features = nn.Sequential(*self.features)
# building last several layers
self.conv_last = conv_1x1_bn(input_channel, self.stage_out_channels[-1])
self.globalpool = nn.Sequential(nn.AvgPool2d(int(input_size/32)))
# building classifier
self.classifier = nn.Sequential(nn.Linear(self.stage_out_channels[-1], n_class))
def forward(self, x):
y = []
conv1 = self.conv1(x)
maxpool = self.maxpool(conv1)
y.append(maxpool)
out3 = self.stage2(maxpool)
y.append(out3)
out4 = self.stage3(out3)
y.append(out4)
out5 = self.stage4(out4)
y.append(out5)
if self.back_flag:
return y
#x = self.features(x)
x = self.conv_last(out5)
x = self.globalpool(x)
x = x.view(-1, self.stage_out_channels[-1])
x = self.classifier(x)
return x
def shufflenetv2(width_mult=1.):
model = ShuffleNetV2(width_mult=width_mult)
return model
if name == "main":
"""Testing
"""
model = ShuffleNetV2()
print(model)
`
If I train my own data, but it is different from the number of categories in the coco data set, where should I modify it? Thank you
您好,请问该代码和原论文结果相比,精度怎样?
Could you provide the train procedure and data preparation( such as data file catalogue ,where should i put the VOC data ?) in detail?
您好,程序卡在data = next(data_iter),loss等都是nan,请问是python版本问题吗,我用的是3.5
您好!我训练自己的数据,格式和VOC一致,类别也改过,也调过lr,但是一训练就出现loss=nan;数据是kitti数据集,以前训练过其它网络,数据应该没问题;请问我有漏改了什么吗?
感谢分享,项目中的psroialign模块好像有点问题,build之后跑不通,我将你项目中的psroialign模块替换为https://github.com/McDo/PSROIAlign-Multi-Batch-PyTorch.git 项目,稍作修改后跑通了。然而,训练了两百多个epoch后使用testing.py进行测试,模型没有检测出任何一个框。整个训练过程中loss是下降的,我想用你的预训练模型测试一下,请问方便吗?我使用的训练数据为voc
请问一下,测试网络时支持多batchsize输入还是只能单batchsize?
Hi. I found that the extractor conv1 and stage 1 are frozen. Why freeze these parameters?
It seems that the channels in branch_main and branch_proj should be out_channel // 2, but you use the inp here.
https://github.com/ouyanghuiyu/Thundernet_Pytorch/blob/master/lib/model/faster_rcnn/modules.py#L289
楼主好,我在训练过程中,发现迭代的速度比较慢,大约30多秒迭代一步,正常吗?
这个错误怎么解决
感谢大佬的复现!请问大佬能否将复现的结果放在readme里面,我比较好奇320分辨率下sn49,sn146,sn535的flops以及在voc07上的map
如题,训练的时候一直都报这个警告。loss一直未nan。请问各位大佬怎么解决?
[epoch 3][iter 0/ 110] loss: nan, lr: 1.00e-10, rpn_cls: nan, rpn_box: nan, rcnn_cls: 2.2976, rcnn_box 0.0000 size:(240,240)
WARNING:root:NaN or Inf found in input tensor.
WARNING:root:NaN or Inf found in input tensor.
WARNING:root:NaN or Inf found in input tensor.
Hi, i met the error when i train my own data and the error like this:
Traceback (most recent call last):
File "trainval_net.py", line 484, in
rois_label = _RCNN(im_data, im_info, gt_boxes, num_boxes,
File "/home/mario/.conda/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/home/mario/Projects/Obj_det/faster-rcnn.pytorch-pytorch-1.0/lib/model/faster_rcnn/faster_rcnn.py", line 51, in forward
base_feat = self.RCNN_base(im_data)
File "/home/mario/.conda/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/home/mario/Projects/Obj_det/Thundernet_Pytorch/lib/model/faster_rcnn/Snet.py", line 147, in forward
return cem_out
UnboundLocalError: local variable 'cem_out' referenced before assignment
could you please tell me how to fix it. thanks:)
Hi,I've got a 'Segmentation fault (core dumped)' when I run your code.
The code got wrong in 'Engine.py' line 31, do you know why??
No module named 'external.nms'
Hi, could you provide me the training SNet code from scratch? I think a good SNet backbone model is very important for further thundernet performance. I want to train the Snet from scratch. Thx.
Hi @ouyanghuiyu
Is there any official implementation of this paper where we can reproduce the reported results in the paper?
Thanks
非常感谢您的工作,请问backbone现在有预训练模型吗?如果没有的话精度上会有多少损失?
Many thanks for your good job!
May I ask about the accuracy on Imagenet of your Snet146? A 32.5% top-1 error is reported in the paper. Not sure your SNet achieves this or not.
使用自己的voc格式的数据集进行了训练和验证,MAP不是很高,但是可以检测出我们所需要的类别,只是为什么模型输出的是分割颜色区别,为什么不是检测框? 另外如何使用该模型去进行视频测试? 麻烦楼主解答一下,谢谢您了。
可爱的楼主您好~我单卡训练没问题,多卡训练报错
Traceback (most recent call last):
File "trainval_net.py", line 479, in
rois_label = _RCNN(im_data, im_info, gt_boxes, num_boxes,
File "/home/xinjianli/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/home/xinjianli/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 153, in forward
return self.gather(outputs, self.output_device)
File "/home/xinjianli/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 165, in gather
return gather(outputs, output_device, dim=self.dim)
File "/home/xinjianli/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 68, in gather
res = gather_map(outputs)
File "/home/xinjianli/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 63, in gather_map
return type(out)(map(gather_map, zip(*outputs)))
File "/home/xinjianli/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 63, in gather_map
return type(out)(map(gather_map, zip(*outputs)))
File "/home/xinjianli/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 63, in gather_map
return type(out)(map(gather_map, zip(*outputs)))
TypeError: zip argument #1 must support iteration
#!/bin/bash
set -e
cd ..
CUDA_VISIBLE_DEVICES=18,19,20,21 python trainval_net.py --dataset pascal_voc_0712 --net snet_146 --bs 256 --nw 16
--lr 1e-2 --epochs 150 --cuda --lr_decay_step 25,50,75 --use_tfboard True
--save_dir snet146 --eval_interval 2 --logdir snet146_log --pre ./weights/snet_146.tar
--checkepoch 2 --mgpus
hi,Thanks for your contributing!I train the model on KITTI dataset,only one class=‘car’;but the AP and AR are low,are 0.23 and 0.4 respectively;The FPS i test on 1050Ti are 50,is it any problem?
Could you please give me instructions how I could train network on custom dataset in VOC format.
GPU上预测结果一切正常,将代码拷贝到另外一台CPU服务器上,CPU可以运行,但没有预测框。请问作者试过在CPU上运行代码吗?结果是正确的吗?
Hi,
我想问下,是不是需要预训练文件的放入?
当我运行sh. train_146.sh 的时候
作者有没有训练好的预训练模型,方便分享一下
snet146/snet_146/pascal_voc7012/thundernet_epoch_2.pth
I tested the classificaiton accuracy of the pretrained model and get Top1 0.082 and Top5 0.444. This is weired. Why is it so low? Anyone who tests it as well?
I ran the test in the CPU with the following error:
load checkpoint weights/snet_146/pascal_voc_0712/thundernet_epoch_6.pth
load model successfully!
load checkpoint weights/snet_146/pascal_voc_0712/thundernet_epoch_6.pth
Loaded Photo: 0 images.
/home/silence/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:1351: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
Traceback (most recent call last):
File "demo.py", line 328, in
rois_label = _RCNN(im_data, im_info, gt_boxes, num_boxes)
File "/home/silence/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/silence/cvdata/Thundernet_Pytorch-master/lib/model/faster_rcnn/faster_rcnn.py", line 126, in forward
pooled_feat = self._roi_align_layer(base_feat, rois.view(-1, 5))
File "/home/silence/cvdata/Thundernet_Pytorch-master/lib/model/faster_rcnn/faster_rcnn.py", line 68, in _roi_align_layer
return self.psroiAlign.forward(bottom, rois)
File "/home/silence/cvdata/Thundernet_Pytorch-master/lib/psroialign/psroialign.py", line 19, in forward
pooled_feat = self.psroialign(feat, rois)
File "/home/silence/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/silence/cvdata/Thundernet_Pytorch-master/lib/psroialign/PSROIAlign/model/roi_layers/ps_roi_align.py", line 77, in forward
self.pooled_dim # 10
File "/home/silence/cvdata/Thundernet_Pytorch-master/lib/psroialign/PSROIAlign/model/roi_layers/ps_roi_align.py", line 33, in forward
raise NotImplementedError
NotImplementedError
good job!!
Hi
请问支持视频的实时识别吗,如果我要更改其中的code,能否告知其中哪个函数,多谢
As far as I know, there is no onnx support for psroialign yet. Does anybody know there is any support for this?
您好,我尝试使用您的代码跑VOC,但是得到了很低的结果(AP,AP50等,接近于0),检测结果也不是很好,请问您出现过这种情况吗?谢谢!
您好,请问我在执行:python setup.py build_ext --inplace的时候出现下列错误:
error C1189: #error: pybind11 requires MSVC 2015 update 3 or newer
error: command 'D:\VS2015\VC\BIN\x86_amd64\cl.exe' failed with exit status 2
请问我该怎么解决呢,我是目标检测小白
有没有遇到相同问题的小伙伴可以解决一下
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.