Python resnet.ResNet() Examples

The following are 4 code examples of resnet.ResNet(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module resnet , or try the search function .
Example #1
Source File: demo.py    From blitznet with MIT License 6 votes vote down vote up
def main(argv=None):  # pylint: disable=unused-argument
    assert args.detect or args.segment, "Either detect or segment should be True"
    assert args.ckpt > 0, "Specify the number of checkpoint"
    net = ResNet(config=net_config, depth=50, training=False)
    loader = Loader(osp.join(EVAL_DIR, 'demodemo'))


    with tf.Session(config=tf.ConfigProto(allow_soft_placement=True,
                                          log_device_placement=False)) as sess:
        detector = Detector(sess, net, loader, net_config, no_gt=args.no_seg_gt,
                            folder=osp.join(loader.folder, 'output'))
        detector.restore_from_ckpt(args.ckpt)
        for name in loader.get_filenames():
            image = loader.load_image(name)
            h, w = image.shape[:2]
            print('Processing {}'.format(name + loader.data_format))
            detector.feed_forward(img=image, name=name, w=w, h=h, draw=True,
                                  seg_gt=None, gt_bboxes=None, gt_cats=None)
    print('Done') 
Example #2
Source File: keypoint_net.py    From MIT-Driverless-CV-TrainingInfra with Apache License 2.0 6 votes vote down vote up
def __init__(self, num_kpt=7, image_size=(80, 80), onnx_mode=False, init_weight=True):
        super(KeypointNet, self).__init__()
        net_size = 16

        self.conv = nn.Conv2d(in_channels=3, out_channels=net_size, kernel_size=7, stride=1, padding=3)
        # torch.nn.init.xavier_uniform(self.conv.weight)
        self.bn = nn.BatchNorm2d(net_size)
        self.relu = nn.ReLU()
        self.res1 = ResNet(net_size, net_size)
        self.res2 = ResNet(net_size, net_size * 2)
        self.res3 = ResNet(net_size * 2, net_size * 4)
        self.res4 = ResNet(net_size * 4, net_size * 8)
        self.out = nn.Conv2d(in_channels=net_size * 8, out_channels=num_kpt, kernel_size=1, stride=1, padding=0)
        # torch.nn.init.xavier_uniform(self.out.weight)
        if init_weight:
            self._initialize_weights()
        self.image_size = image_size
        self.num_kpt = num_kpt
        self.onnx_mode = onnx_mode 
Example #3
Source File: main.py    From blitznet with MIT License 5 votes vote down vote up
def init_detectot(self):
        assert args.detect or args.segment, "Either detect or segment should be True"
        assert args.ckpt > 0, "Specify the number of checkpoint"
        net = ResNet(config=net_config, depth=50, training=False)
        self.loader = Loader(opj(EVAL_DIR, 'demodemo'))
        self.detector = Detector(self.sess, net, self.loader, net_config, no_gt=args.no_seg_gt,
                                 folder=opj(self.loader.folder, 'output'))
        self.detector.restore_from_ckpt(args.ckpt) 
Example #4
Source File: net_base.py    From TF_Face_Toolbox with Apache License 2.0 4 votes vote down vote up
def net_select(name, data_format='NCHW', weight_decay=5e-4):
  if name == 'SphereNet':
    from sphere import SphereNet
    network = SphereNet(data_format=data_format, 
                        weight_decay=weight_decay)  
  elif name == 'ResNeXt-26':
    from resnext import ResNeXt
    network = ResNeXt(num_layers=26, num_card=32, 
                      data_format=data_format, 
                      weight_decay=weight_decay)
  elif name == 'ResNet-50':
    from resnet import ResNet
    network = ResNet(num_layers=50, 
                     data_format=data_format, 
                     weight_decay=weight_decay)
  elif name == 'ShuffleNet-v2-small':
    from shufflenet_v2 import ShuffleNet_v2_small
    network = ShuffleNet_v2_small(alpha=2.0, 
                                  se=False, residual=False,
                                  data_format=data_format, 
                                  weight_decay=weight_decay)
  elif name == 'ShuffleNet-v2-middle':
    from shufflenet_v2 import ShuffleNet_v2_middle
    network = ShuffleNet_v2_middle(se=False, residual=False,
                                   data_format=data_format, 
                                   weight_decay=weight_decay)
  elif name == 'ShuffleNet-v2-large':
    from shufflenet_v2 import ShuffleNet_v2_large
    network = ShuffleNet_v2_large(data_format=data_format, 
                                  weight_decay=weight_decay)
  elif name == 'MobileNet-v2':
    pass
  elif name == 'Inception-v4':
    pass
  elif name == 'VGG16':
    pass
  elif name == 'AlexNet':
    pass
  else:
    raise ValueError('Unsupport network architecture.')

  return network