Пример #1
1
  # output directory where the models are saved
  output_dir = get_output_dir(imdb, args.tag)
  print('Output will be saved to `{:s}`'.format(output_dir))

  # tensorboard directory where the summaries are saved during training
  tb_dir = get_output_tb_dir(imdb, args.tag)
  print('TensorFlow summaries will be saved to `{:s}`'.format(tb_dir))

  # also add the validation set, but with no flipping images
  orgflip = cfg.TRAIN.USE_FLIPPED
  cfg.TRAIN.USE_FLIPPED = False
  _, valroidb = combined_roidb(args.imdbval_name)
  print('{:d} validation roidb entries'.format(len(valroidb)))
  cfg.TRAIN.USE_FLIPPED = orgflip

  # load network
  if args.net == 'vgg16':
    net = vgg16(batch_size=cfg.TRAIN.IMS_PER_BATCH)
  elif args.net == 'res50':
    net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=50)
  elif args.net == 'res101':
    net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=101)
  elif args.net == 'res152':
    net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=152)
  else:
    raise NotImplementedError
    
  train_net(net, imdb, roidb, valroidb, output_dir, tb_dir,
            pretrained_model=args.weight,
            max_iters=args.max_iters)
    tag = tag if tag else 'default'
    filename = tag + '/' + filename

    imdb = get_imdb(args.imdb_name)
    imdb.competition_mode(args.comp_mode)

    tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.allow_growth = True

    # init session
    sess = tf.Session(config=tfconfig)
    # load network
    if args.net == 'vgg16':
        net = vgg16()
    elif args.net == 'res50':
        net = resnetv1(num_layers=50)
    elif args.net == 'res101':
        net = resnetv1(num_layers=101)
    elif args.net == 'res152':
        net = resnetv1(num_layers=152)
    elif args.net == 'mobile':
        net = mobilenetv1()
    else:
        raise NotImplementedError

    # load model
    with tf.variable_scope('rpn_network'):
        net.create_architecture(sess,
                                "TEST",
                                imdb.num_classes,
                                tag='default',
Пример #3
0
            ('{:s} not found.\nDid you download the proper networks from '
             'our server and place them properly?').format(tfmodel + '.meta'))

    # set config
    tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.allow_growth = True
    print("\033[1;34mThe code is licensed by engineer1109.")
    #print ("\033[1;34m开始初始化系统")
    # init session
    sess = tf.Session(config=tfconfig)
    #print ("\033[1;33m卷积模型开始加载,默认是RES101")
    # load network
    if demonet == 'vgg16':
        net = vgg16(batch_size=1)
    elif demonet == 'res101':
        net = resnetv1(batch_size=1, num_layers=101)
    else:
        raise NotImplementedError
    #print(demonet)
    net.create_architecture(sess,
                            "TEST",
                            37,
                            tag='default',
                            anchor_scales=[8, 16, 32])
    saver = tf.train.Saver()
    saver.restore(sess, tfmodel)
    #print(saver.restore(sess, tfmodel))

    #print('网络加载完毕 {:s}'.format(tfmodel))
    result = []
    fd = file("images.txt", "r")
Пример #4
0
    # tensorboard directory where the summaries are saved during training
    tb_dir = get_output_tb_dir(imdb, args.tag)
    print('TensorFlow summaries will be saved to `{:s}`'.format(tb_dir))

    # also add the validation set, but with no flipping images
    orgflip = cfg.TRAIN.USE_FLIPPED
    cfg.TRAIN.USE_FLIPPED = False
    _, valroidb = combined_roidb(args.imdbval_name)
    print('{:d} validation roidb entries'.format(len(valroidb)))
    cfg.TRAIN.USE_FLIPPED = orgflip

    # load network
    if args.net == 'vgg16':
        net = vgg16(batch_size=cfg.TRAIN.IMS_PER_BATCH)
    elif args.net == 'res50':
        net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=50)
    elif args.net == 'res101':
        net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=101)
    elif args.net == 'res152':
        net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=152)
    else:
        raise NotImplementedError

    train_net(net,
              imdb,
              roidb,
              valroidb,
              output_dir,
              tb_dir,
              pretrained_model=args.weight,
              max_iters=args.max_iters)
Пример #5
0
  tag = tag if tag else 'default'
  filename = tag + '/' + filename

  imdb = get_imdb(args.imdb_name)
  imdb.competition_mode(args.comp_mode)

  tfconfig = tf.ConfigProto(allow_soft_placement=True)
  tfconfig.gpu_options.allow_growth=True

  # init session
  sess = tf.Session(config=tfconfig)
  # load network
  if args.net == 'vgg16':
    net = vgg16()
  elif args.net == 'res50':
    net = resnetv1(num_layers=50)
  elif args.net == 'res101':
    net = resnetv1(num_layers=101)
  elif args.net == 'res152':
    net = resnetv1(num_layers=152)
  elif args.net == 'mobile':
    net = mobilenetv1()
  else:
    raise NotImplementedError

  # load model
  with tf.variable_scope('rpn_network'):
    net.create_architecture(sess, "TEST", imdb.num_classes, tag='default',
                            anchor_scales=cfg.ANCHOR_SCALES,
                            anchor_ratios=cfg.ANCHOR_RATIOS)
        filename = os.path.splitext(os.path.basename(args.weight))[0]

    tag = args.tag
    tag = tag if tag else 'default'
    filename = tag + '/' + filename

    imdb = get_imdb(args.imdb_name)
    imdb.competition_mode(args.comp_mode)

    tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.allow_growth = True

    # init session
    sess = tf.Session(config=tfconfig)

    net = resnetv1(num_layers=101)

    # load model
    net.create_architecture(sess,
                            "TEST",
                            imdb.num_classes,
                            tag='default',
                            anchor_scales=cfg.ANCHOR_SCALES,
                            anchor_ratios=cfg.ANCHOR_RATIOS)

    print(('Loading model check point from {:s}').format(args.model))
    saver = tf.train.Saver()
    saver.restore(sess, args.model)

    test_net(sess, net, imdb, filename, max_per_image=args.max_per_image)
    # for var in tf.all_variables():