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

CornerNet has recently been upgraded to CornerNet-Lite, and has made great progress. Do you have a comparison of the efficiency and time of testing with CornerNet's AP detection? #24

Open
QQ2737499951 opened this issue May 4, 2019 · 5 comments

Comments

@QQ2737499951
Copy link

CornerNet has recently been upgraded to CornerNet-Lite, and has made great progress. Do you have a comparison of the efficiency and time of testing with CornerNet's AP detection? THX!

https://github.com/princeton-vl/CornerNet-Lite

Code for reproducing results in the following paper:

CornerNet-Lite: Efficient Keypoint Based Object Detection CornerNet-Lite:基于关键点的高效对象检测
Hei Law, Yun Teng, Olga Russakovsky, Jia Deng
arXiv:1904.08900

@Duankaiwen
Copy link
Owner

Sorry, we have not yet.

@QQ2737499951
Copy link
Author

QQ2737499951 commented May 6, 2019

**Can you help me add the parameters of CenterNet to the model files CornerNet_Saccade.py and CornerNet_Squeeze.py?Thank you very much!

Because the format of CornerNet-Lite's training model file has changed, and I have successfully trained CornerNet-Lite, just need to modify the parameters and add your CenterNet parameters. Thank you!**

Email:2737499951@QQ.COM

https://github.com/princeton-vl/CornerNet-Lite/tree/master/core/models

form https://github.com/princeton-vl/CornerNet-Lite/blob/master/core/models/CornerNet_Saccade.py

#CornerNet_Saccade.py

=====================

form https://github.com/princeton-vl/CornerNet-Lite/blob/master/core/models/CornerNet_Squeeze.py

#CornerNet_Squeeze.py

@QQ2737499951
Copy link
Author

QQ2737499951 commented May 6, 2019

Sorry, we have not yet.

**Can you help me add the parameters of CenterNet to the model files CornerNet_Saccade.py and CornerNet_Squeeze.py?Thank you very much!

Because the format of CornerNet-Lite's training model file has changed, and I have successfully trained CornerNet-Lite, just need to modify the parameters and add your CenterNet parameters. Thank you!**

Email:2737499951@QQ.COM

https://github.com/princeton-vl/CornerNet-Lite/tree/master/core/models

form https://github.com/princeton-vl/CornerNet-Lite/blob/master/core/models/CornerNet_Saccade.py
#CornerNet_Saccade.py
#@heilaw heilaw first commit
#0ecad35 18 days ago
#92 lines (76 sloc) 3.42 KB

`import torch
import torch.nn as nn

from .py_utils import TopPool, BottomPool, LeftPool, RightPool

from .py_utils.utils import convolution, residual, corner_pool
from .py_utils.losses import CornerNet_Saccade_Loss
from .py_utils.modules import saccade_net, saccade_module, saccade

def make_pool_layer(dim):
return nn.Sequential()

def make_hg_layer(inp_dim, out_dim, modules):
layers = [residual(inp_dim, out_dim, stride=2)]
layers += [residual(out_dim, out_dim) for _ in range(1, modules)]
return nn.Sequential(*layers)

class model(saccade_net):
def _pred_mod(self, dim):
return nn.Sequential(
convolution(3, 256, 256, with_bn=False),
nn.Conv2d(256, dim, (1, 1))
)

def _merge_mod(self):
return nn.Sequential(
nn.Conv2d(256, 256, (1, 1), bias=False),
nn.BatchNorm2d(256)
)

def init(self):
stacks = 3
pre = nn.Sequential(
convolution(7, 3, 128, stride=2),
residual(128, 256, stride=2)
)
hg_mods = nn.ModuleList([
saccade_module(
3, [256, 384, 384, 512], [1, 1, 1, 1],
make_pool_layer=make_pool_layer,
make_hg_layer=make_hg_layer
) for _ in range(stacks)
])
cnvs = nn.ModuleList([convolution(3, 256, 256) for _ in range(stacks)])
inters = nn.ModuleList([residual(256, 256) for _ in range(stacks - 1)])
cnvs_ = nn.ModuleList([self.merge_mod() for _ in range(stacks - 1)])
inters
= nn.ModuleList([self._merge_mod() for _ in range(stacks - 1)])

att_mods = nn.ModuleList([
    nn.ModuleList([
        nn.Sequential(
            convolution(3, 384, 256, with_bn=False),
            nn.Conv2d(256, 1, (1, 1))
        ),
        nn.Sequential(
            convolution(3, 384, 256, with_bn=False),
            nn.Conv2d(256, 1, (1, 1))
        ),
        nn.Sequential(
            convolution(3, 256, 256, with_bn=False),
            nn.Conv2d(256, 1, (1, 1))
        )
    ]) for _ in range(stacks)
])
for att_mod in att_mods:
    for att in att_mod:
        torch.nn.init.constant_(att[-1].bias, -2.19)

hgs = saccade(pre, hg_mods, cnvs, inters, cnvs_, inters_) 

tl_modules = nn.ModuleList([corner_pool(256, TopPool, LeftPool) for _ in range(stacks)])
br_modules = nn.ModuleList([corner_pool(256, BottomPool, RightPool) for _ in range(stacks)])

tl_heats = nn.ModuleList([self._pred_mod(80) for _ in range(stacks)])
br_heats = nn.ModuleList([self._pred_mod(80) for _ in range(stacks)])
for tl_heat, br_heat in zip(tl_heats, br_heats):
    torch.nn.init.constant_(tl_heat[-1].bias, -2.19)
    torch.nn.init.constant_(br_heat[-1].bias, -2.19)

tl_tags = nn.ModuleList([self._pred_mod(1) for _ in range(stacks)])
br_tags = nn.ModuleList([self._pred_mod(1) for _ in range(stacks)])

tl_offs = nn.ModuleList([self._pred_mod(2) for _ in range(stacks)])
br_offs = nn.ModuleList([self._pred_mod(2) for _ in range(stacks)])

super(model, self).__init__(
    hgs, tl_modules, br_modules, tl_heats, br_heats, 
    tl_tags, br_tags, tl_offs, br_offs, att_mods
)

self.loss = CornerNet_Saccade_Loss(pull_weight=1e-1, push_weight=1e-1)`

=====================

form https://github.com/princeton-vl/CornerNet-Lite/blob/master/core/models/CornerNet_Squeeze.py
#CornerNet_Squeeze.py
#@heilaw heilaw first commit
#0ecad35 18 days ago
112 lines (92 sloc) 4.4 KB

`import torch
import torch.nn as nn

from .py_utils import TopPool, BottomPool, LeftPool, RightPool

from .py_utils.utils import convolution, corner_pool, residual
from .py_utils.losses import CornerNet_Loss
from .py_utils.modules import hg_module, hg, hg_net

class fire_module(nn.Module):
def init(self, inp_dim, out_dim, sr=2, stride=1):
super(fire_module, self).init()
self.conv1 = nn.Conv2d(inp_dim, out_dim // sr, kernel_size=1, stride=1, bias=False)
self.bn1 = nn.BatchNorm2d(out_dim // sr)
self.conv_1x1 = nn.Conv2d(out_dim // sr, out_dim // 2, kernel_size=1, stride=stride, bias=False)
self.conv_3x3 = nn.Conv2d(out_dim // sr, out_dim // 2, kernel_size=3, padding=1,
stride=stride, groups=out_dim // sr, bias=False)
self.bn2 = nn.BatchNorm2d(out_dim)
self.skip = (stride == 1 and inp_dim == out_dim)
self.relu = nn.ReLU(inplace=True)

def forward(self, x):
conv1 = self.conv1(x)
bn1 = self.bn1(conv1)
conv2 = torch.cat((self.conv_1x1(bn1), self.conv_3x3(bn1)), 1)
bn2 = self.bn2(conv2)
if self.skip:
return self.relu(bn2 + x)
else:
return self.relu(bn2)
def make_pool_layer(dim):
return nn.Sequential()

def make_unpool_layer(dim):
return nn.ConvTranspose2d(dim, dim, kernel_size=4, stride=2, padding=1)

def make_layer(inp_dim, out_dim, modules):
layers = [fire_module(inp_dim, out_dim)]
layers += [fire_module(out_dim, out_dim) for _ in range(1, modules)]
return nn.Sequential(*layers)

def make_layer_revr(inp_dim, out_dim, modules):
layers = [fire_module(inp_dim, inp_dim) for _ in range(modules - 1)]
layers += [fire_module(inp_dim, out_dim)]
return nn.Sequential(*layers)

def make_hg_layer(inp_dim, out_dim, modules):
layers = [fire_module(inp_dim, out_dim, stride=2)]
layers += [fire_module(out_dim, out_dim) for _ in range(1, modules)]
return nn.Sequential(*layers)

class model(hg_net):
def _pred_mod(self, dim):
return nn.Sequential(
convolution(1, 256, 256, with_bn=False),
nn.Conv2d(256, dim, (1, 1))
)

def _merge_mod(self):
return nn.Sequential(
nn.Conv2d(256, 256, (1, 1), bias=False),
nn.BatchNorm2d(256)
)

def init(self):
stacks = 2
pre = nn.Sequential(
convolution(7, 3, 128, stride=2),
residual(128, 256, stride=2),
residual(256, 256, stride=2)
)
hg_mods = nn.ModuleList([
hg_module(
4, [256, 256, 384, 384, 512], [2, 2, 2, 2, 4],
make_pool_layer=make_pool_layer,
make_unpool_layer=make_unpool_layer,
make_up_layer=make_layer,
make_low_layer=make_layer,
make_hg_layer_revr=make_layer_revr,
make_hg_layer=make_hg_layer
) for _ in range(stacks)
])
cnvs = nn.ModuleList([convolution(3, 256, 256) for _ in range(stacks)])
inters = nn.ModuleList([residual(256, 256) for _ in range(stacks - 1)])
cnvs_ = nn.ModuleList([self.merge_mod() for _ in range(stacks - 1)])
inters
= nn.ModuleList([self._merge_mod() for _ in range(stacks - 1)])

hgs = hg(pre, hg_mods, cnvs, inters, cnvs_, inters_) 

tl_modules = nn.ModuleList([corner_pool(256, TopPool, LeftPool) for _ in range(stacks)])
br_modules = nn.ModuleList([corner_pool(256, BottomPool, RightPool) for _ in range(stacks)])

tl_heats = nn.ModuleList([self._pred_mod(80) for _ in range(stacks)])
br_heats = nn.ModuleList([self._pred_mod(80) for _ in range(stacks)])
for tl_heat, br_heat in zip(tl_heats, br_heats):
    torch.nn.init.constant_(tl_heat[-1].bias, -2.19)
    torch.nn.init.constant_(br_heat[-1].bias, -2.19)

tl_tags = nn.ModuleList([self._pred_mod(1) for _ in range(stacks)])
br_tags = nn.ModuleList([self._pred_mod(1) for _ in range(stacks)])

tl_offs = nn.ModuleList([self._pred_mod(2) for _ in range(stacks)])
br_offs = nn.ModuleList([self._pred_mod(2) for _ in range(stacks)])

super(model, self).__init__(
    hgs, tl_modules, br_modules, tl_heats, br_heats, 
    tl_tags, br_tags, tl_offs, br_offs
)

self.loss = CornerNet_Loss(pull_weight=1e-1, push_weight=1e-1)`

@QQ2737499951
Copy link
Author

WIN10下已经解决了安装和训练,还有问题的,可以加Q群264191384 注明(CenterNet)共同研究,谢谢

@mochechan
Copy link

Cornernet_Lite is an enhancement of Cornernet with the same backbone network.
Cornernet_Lite has better inference speed and higher mAP than Cornernet.
Centernet uses most parts of backbone network of Cornernet.
Combination of Centernet and Cornernet_Lite should be a nice work that I interested in.

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