Safemotion Lib
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
fastreid.modeling.backbones.osnet.OSNet Class Reference
Inheritance diagram for fastreid.modeling.backbones.osnet.OSNet:

Public Member Functions

 __init__ (self, blocks, layers, channels, bn_norm, IN=False, **kwargs)
 
 forward (self, x)
 

Public Attributes

 conv1
 
 maxpool
 
 conv2
 
 conv3
 
 conv4
 
 conv5
 

Protected Member Functions

 _make_layer (self, block, layer, in_channels, out_channels, bn_norm, reduce_spatial_size, IN=False)
 
 _init_params (self)
 

Detailed Description

Omni-Scale Network.

Reference:
    - Zhou et al. Omni-Scale Feature Learning for Person Re-Identification. ICCV, 2019.
    - Zhou et al. Learning Generalisable Omni-Scale Representations
      for Person Re-Identification. arXiv preprint, 2019.

Definition at line 289 of file osnet.py.

Constructor & Destructor Documentation

◆ __init__()

fastreid.modeling.backbones.osnet.OSNet.__init__ ( self,
blocks,
layers,
channels,
bn_norm,
IN = False,
** kwargs )

Definition at line 298 of file osnet.py.

306 ):
307 super(OSNet, self).__init__()
308 num_blocks = len(blocks)
309 assert num_blocks == len(layers)
310 assert num_blocks == len(channels) - 1
311
312 # convolutional backbone
313 self.conv1 = ConvLayer(3, channels[0], 7, bn_norm, stride=2, padding=3, IN=IN)
314 self.maxpool = nn.MaxPool2d(3, stride=2, padding=1)
315 self.conv2 = self._make_layer(
316 blocks[0],
317 layers[0],
318 channels[0],
319 channels[1],
320 bn_norm,
321 reduce_spatial_size=True,
322 IN=IN
323 )
324 self.conv3 = self._make_layer(
325 blocks[1],
326 layers[1],
327 channels[1],
328 channels[2],
329 bn_norm,
330 reduce_spatial_size=True
331 )
332 self.conv4 = self._make_layer(
333 blocks[2],
334 layers[2],
335 channels[2],
336 channels[3],
337 bn_norm,
338 reduce_spatial_size=False
339 )
340 self.conv5 = Conv1x1(channels[3], channels[3], bn_norm)
341
342 self._init_params()
343

Member Function Documentation

◆ _init_params()

fastreid.modeling.backbones.osnet.OSNet._init_params ( self)
protected

Definition at line 370 of file osnet.py.

370 def _init_params(self):
371 for m in self.modules():
372 if isinstance(m, nn.Conv2d):
373 nn.init.kaiming_normal_(
374 m.weight, mode='fan_out', nonlinearity='relu'
375 )
376 if m.bias is not None:
377 nn.init.constant_(m.bias, 0)
378
379 elif isinstance(m, nn.BatchNorm2d):
380 nn.init.constant_(m.weight, 1)
381 nn.init.constant_(m.bias, 0)
382
383 elif isinstance(m, nn.BatchNorm1d):
384 nn.init.constant_(m.weight, 1)
385 nn.init.constant_(m.bias, 0)
386
387 elif isinstance(m, nn.Linear):
388 nn.init.normal_(m.weight, 0, 0.01)
389 if m.bias is not None:
390 nn.init.constant_(m.bias, 0)
391

◆ _make_layer()

fastreid.modeling.backbones.osnet.OSNet._make_layer ( self,
block,
layer,
in_channels,
out_channels,
bn_norm,
reduce_spatial_size,
IN = False )
protected

Definition at line 344 of file osnet.py.

353 ):
354 layers = []
355
356 layers.append(block(in_channels, out_channels, bn_norm, IN=IN))
357 for i in range(1, layer):
358 layers.append(block(out_channels, out_channels, bn_norm, IN=IN))
359
360 if reduce_spatial_size:
361 layers.append(
362 nn.Sequential(
363 Conv1x1(out_channels, out_channels, bn_norm),
364 nn.AvgPool2d(2, stride=2),
365 )
366 )
367
368 return nn.Sequential(*layers)
369

◆ forward()

fastreid.modeling.backbones.osnet.OSNet.forward ( self,
x )

Definition at line 392 of file osnet.py.

392 def forward(self, x):
393 x = self.conv1(x)
394 x = self.maxpool(x)
395 x = self.conv2(x)
396 x = self.conv3(x)
397 x = self.conv4(x)
398 x = self.conv5(x)
399 return x
400
401

Member Data Documentation

◆ conv1

fastreid.modeling.backbones.osnet.OSNet.conv1

Definition at line 313 of file osnet.py.

◆ conv2

fastreid.modeling.backbones.osnet.OSNet.conv2

Definition at line 315 of file osnet.py.

◆ conv3

fastreid.modeling.backbones.osnet.OSNet.conv3

Definition at line 324 of file osnet.py.

◆ conv4

fastreid.modeling.backbones.osnet.OSNet.conv4

Definition at line 332 of file osnet.py.

◆ conv5

fastreid.modeling.backbones.osnet.OSNet.conv5

Definition at line 340 of file osnet.py.

◆ maxpool

fastreid.modeling.backbones.osnet.OSNet.maxpool

Definition at line 314 of file osnet.py.


The documentation for this class was generated from the following file: