本文整理汇总了Python中model.faster_rcnn.faster_rcnn._fasterRCNN.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python _fasterRCNN.__init__方法的具体用法?Python _fasterRCNN.__init__怎么用?Python _fasterRCNN.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.faster_rcnn.faster_rcnn._fasterRCNN
的用法示例。
在下文中一共展示了_fasterRCNN.__init__方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, block, layers, num_classes=1000):
self.inplanes = 64
super(ResNet, self).__init__()
self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
bias=False)
self.bn1 = nn.BatchNorm2d(64)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=0,
ceil_mode=True) # change
self.layer1 = self._make_layer(block, 64, layers[0])
self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
self.layer4 = self._make_layer(block, 512, layers[3], stride=2)
# it is slightly better whereas slower to set stride = 1
# self.layer4 = self._make_layer(block, 512, layers[3], stride=1)
self.avgpool = nn.AvgPool2d(7)
self.fc = nn.Linear(512 * block.expansion, num_classes)
for m in self.modules():
if isinstance(m, nn.Conv2d):
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
m.weight.data.normal_(0, math.sqrt(2. / n))
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zero_()
示例2: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, block, layers, num_classes=1000):
self.inplanes = 64
super(ResNet, self).__init__()
self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
bias=False)
self.bn1 = nn.BatchNorm2d(64)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=0, ceil_mode=True) # change
self.layer1 = self._make_layer(block, 64, layers[0])
self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
self.layer4 = self._make_layer(block, 512, layers[3], stride=2)
# it is slightly better whereas slower to set stride = 1
# self.layer4 = self._make_layer(block, 512, layers[3], stride=1)
self.avgpool = nn.AvgPool2d(7)
self.fc = nn.Linear(512 * block.expansion, num_classes)
for m in self.modules():
if isinstance(m, nn.Conv2d):
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
m.weight.data.normal_(0, math.sqrt(2. / n))
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zero_()
示例3: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, block, layers, num_classes=1000):
self.inplanes = 64
super(ResNet, self).__init__()
self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
bias=False)
self.bn1 = nn.BatchNorm2d(64)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=0, ceil_mode=True) # change
self.layer1 = self._make_layer(block, 64, layers[0])
self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
self.layer4 = self._make_layer(block, 512, layers[3], stride=2)
# it is slightly better whereas slower to set stride = 1
# self.layer4 = self._make_layer(block, 512, layers[3], stride=1)
self.avgpool = nn.AvgPool2d(7)
self.fc = nn.Linear(512 * block.expansion, num_classes)
for m in self.modules():
if isinstance(m, nn.Conv2d):
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
m.weight.data.normal_(0, math.sqrt(2. / n))
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zero_()
示例4: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, block, layers, num_classes=1000):
self.inplanes = 64
super(ResNet, self).__init__()
self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
bias=False)
self.bn1 = nn.BatchNorm2d(64)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=0, ceil_mode=True) # change
self.layer1 = self._make_layer(block, 64, layers[0])
self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
self.layer4 = self._make_layer(block, 512, layers[3], stride=1, dilation=True)
self.avgpool = nn.AvgPool2d(7)
self.fc = nn.Linear(512 * block.expansion, num_classes)
for m in self.modules():
if isinstance(m, nn.Conv2d):
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
m.weight.data.normal_(0, math.sqrt(2. / n))
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zero_()
示例5: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, classes, pretrained=False, class_agnostic=False):
self.model_path = 'data/pretrained_model/vgg16_caffe.pth'
self.dout_base_model = 512
self.pretrained = pretrained
self.class_agnostic = class_agnostic
_fasterRCNN.__init__(self, classes, class_agnostic)
示例6: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, classes, pretrained=False, class_agnostic=False):
self.model_path = 'data/pretrained_model/vgg16_caffe.pth'
self.dout_base_model = 512
self.pretrained = pretrained
self.class_agnostic = class_agnostic
_fasterRCNN.__init__(self, classes, class_agnostic)
示例7: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, classes, pretrained=False, class_agnostic=False, sup=False):
self.model_path = 'data/pretrained_model/vgg11_caffe.pth'
self.dout_base_model = 512
self.pretrained = pretrained
self.class_agnostic = class_agnostic
_fasterRCNN.__init__(self, classes, class_agnostic, sup)
示例8: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, classes, pretrained=False, class_agnostic=False, sup=False):
self.model_path = 'data/pretrained_model/vgg16_caffe.pth'
self.dout_base_model = 512
self.pretrained = pretrained
self.class_agnostic = class_agnostic
_fasterRCNN.__init__(self, classes, class_agnostic, sup)
示例9: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, classes, version, pretrained=False, class_agnostic=False, lighthead=False):
self.model_path = 'data/pretrained_model/squeezenet{}.pth'.format(version)
self.pretrained = pretrained
self.class_agnostic = class_agnostic
self.lighthead = lighthead
self.version = version
self.dout_base_model = 256
if self.lighthead:
self.dout_lh_base_model = 512
self.clip = None
_fasterRCNN.__init__(self, classes, class_agnostic, lighthead, compact_mode=True)
示例10: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, num_classes=1000):
""" Constructor
Args:
num_classes: number of classes
"""
super(Xception, self).__init__()
self.num_classes = num_classes
self.conv1 = nn.Conv2d(3, 24, kernel_size=3, stride=2, padding=1, bias=False) # 224 x 224 -> 112 x 112
self.bn1 = nn.BatchNorm2d(24)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=0, ceil_mode=True) # -> 56 x 56
# Stage 2
self.block1 = _Block(24, 144, 1+3, 2, start_with_relu=False, grow_first=True) # -> 28 x 28
# Stage 3
self.block2 = _Block(144, 288, 1+7, 2, start_with_relu=True, grow_first=True) # -> 14 x 14
# Stage 4
self.block3 = _Block(288, 576, 1+3, 2, start_with_relu=True, grow_first=True) # -> 7 x 7
self.avgpool = nn.AvgPool2d(7)
self.fc = nn.Linear(576, num_classes)
#------- init weights --------
for m in self.modules():
if isinstance(m, nn.Conv2d):
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
m.weight.data.normal_(0, math.sqrt(2. / n))
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zero_()
#-----------------------------
示例11: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, n_class=1000, input_size=224, width_mult=1.):
super(MobileNetV2, self).__init__()
# setting of inverted residual blocks
self.interverted_residual_setting = [
# t, c, n, s
[1, 16, 1, 1],
[6, 24, 2, 2],
[6, 32, 3, 2],
[6, 64, 4, 2],
[6, 96, 3, 1],
[6, 160, 3, 2],
[6, 320, 1, 1],
]
# building first layer
input_channel = int(32 * width_mult)
self.last_channel = int(1280 * width_mult) if width_mult > 1.0 else 1280
self.features = [conv_bn(3, input_channel, 2)]
# building inverted residual blocks
for t, c, n, s in self.interverted_residual_setting:
output_channel = int(c * width_mult)
for i in range(n):
if i == 0:
self.features.append(InvertedResidual(input_channel, output_channel, s, t))
else:
self.features.append(InvertedResidual(input_channel, output_channel, 1, t))
input_channel = output_channel
# building last several layers
self.features.append(conv_1x1_bn(input_channel, self.last_channel))
self.features.append(nn.AvgPool2d(input_size/32))
# make it nn.Sequential
self.features = nn.Sequential(*self.features)
# building classifier
self.classifier = nn.Sequential(
nn.Dropout(),
nn.Linear(self.last_channel, n_class),
)
示例12: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, classes, num_layers=101, pretrained=False, class_agnostic=False, lighthead=False):
self.model_path = 'data/pretrained_model/resnet101_caffe.pth'
self.pretrained = pretrained
self.class_agnostic = class_agnostic
self.lighthead = lighthead
self.dout_base_model = 1024
if self.lighthead:
self.dout_lh_base_model = 2048
_fasterRCNN.__init__(self, classes, class_agnostic, lighthead, compact_mode=False)
示例13: __init__
# 需要导入模块: from model.faster_rcnn.faster_rcnn import _fasterRCNN [as 别名]
# 或者: from model.faster_rcnn.faster_rcnn._fasterRCNN import __init__ [as 别名]
def __init__(self, classes, pretrained=False, class_agnostic=False, lighthead=False):
self.model_path = 'data/pretrained_model/vgg16_caffe.pth'
self.lighthead = lighthead
self.pretrained = pretrained
self.class_agnostic = class_agnostic
self.dout_base_model = 512
if self.lighthead:
self.dout_lh_base_model = 512
_fasterRCNN.__init__(self, classes, class_agnostic, lighthead, compact_mode=True)