예제 #1
0
    b_size = 10000 if args.num >= 10000 else args.num  # This command is useless because the two dataset HICO-DEt and HOI-COCO have less 10000 verbs.
    b_size = len(verb_feats) if b_size >= len(verb_feats) else b_size

    tfconfig = tf.ConfigProto(device_count={"CPU": 12},
                              inter_op_parallelism_threads=8,
                              intra_op_parallelism_threads=8,
                              allow_soft_placement=True)
    # tfconfig.gpu_options.per_process_gpu_memory_fraction = 0.2
    tfconfig.gpu_options.allow_growth = True
    sess = tf.Session(config=tfconfig)

    # Generate_HICO_detection(output_file, HICO_dir)
    if args.model.__contains__('res101'):
        os.environ['DATASET'] = 'HICO_res101'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    elif args.model.__contains__('VCOCO'):
        os.environ['DATASET'] = 'VCOCO1'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    else:
        from networks.HOI import HOI
        net = HOI(model_name=args.model)

    real_dataset_name = args.dataset if not args.dataset.startswith(
        'gtobj365_coco') else 'gtobj365_coco'
    output_file = cfg.LOCAL_DATA + '/feats/' + str(
        args.iteration) + '_' + args.model + '_{}_{}.pkl'.format(
            args.dataset, args.num)
    print(output_file)
    # if os.path.exists(output_file):
예제 #2
0
    tfconfig = tf.ConfigProto(device_count={"CPU": 12},
                              inter_op_parallelism_threads=8,
                              intra_op_parallelism_threads=8,
                              allow_soft_placement=True)
    # init session

    tfconfig.gpu_options.per_process_gpu_memory_fraction = 0.2

    sess = tf.Session(config=tfconfig)

    # Generate_HICO_detection(output_file, HICO_dir)
    if args.model.__contains__('res101'):
        os.environ['DATASET'] = 'HICO_res101'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    else:
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    stride = 200

    image, blobs, image_id = obtain_test_dataset1(args.object_thres,
                                                  args.human_thres,
                                                  stride=stride,
                                                  test_type=args.test_type,
                                                  model_name=args.model)

    tmp_labels = tf.one_hot(tf.reshape(tf.cast(blobs['O_cls'], tf.int32),
                                       shape=[
                                           -1,
                                       ]),
예제 #3
0
    tb_dir = cfg.ROOT_DIR + '/logs/' + args.model + '/'

    # output directory where the models are saved
    output_dir = cfg.ROOT_DIR + '/Weights/' + args.model + '/'
    if os.path.exists(output_dir + 'checkpoint'):
        args.Restore_flag = -1

    if args.model.__contains__('unique_weights'):
        args.Restore_flag = 6

    augment_type = get_augment_type(args.model)

    if args.model.__contains__('res101'):
        os.environ['DATASET'] = 'HICO_res101'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    else:
        from networks.HOI import HOI
        net = HOI(model_name=args.model)

    with_pose = False
    # if args.model.__contains__('pose'):
    #     with_pose = True

    zero_shot_type = get_zero_shot_type(args.model)
    assert args.model.__contains__('multi')

    image, image_id, num_pos, Human_augmented, Object_augmented, action_HO, sp = obtain_data1(
        Pos_augment=args.Pos_augment,
        Neg_select=args.Neg_select,
        augment_type=augment_type,
예제 #4
0
          ', path = ' + weight)

    output_file = cfg.ROOT_DIR + '/Results/' + str(
        args.iteration) + '_' + args.model + '.pkl'

    # init session
    # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.2)

    tfconfig = tf.ConfigProto(gpu_options=tf.GPUOptions(
        per_process_gpu_memory_fraction=0.2))
    # tfconfig.gpu_options.allow_growth=True
    sess = tf.Session(config=tfconfig)

    iCAN_Early_flag = 0
    import os
    os.environ['DATASET'] = 'VCOCO'
    from networks.HOI import HOI
    net = HOI(args.model)
    net.create_architecture(False)

    saver = tf.train.Saver()
    saver.restore(sess, weight)

    print('Pre-trained weights loaded.')

    test_net(sess, net, Test_RCNN, prior_mask, Action_dic_inv, output_file,
             args.object_thres, args.human_thres, args.prior_flag)
    sess.close()

    vcocoeval._do_eval(output_file, ovr_thresh=0.5)
예제 #5
0
    sess = tf.Session(config=tfconfig)

    # if args.model == 'iCAN_ResNet50_VCOCO':
    #     from networks.iCAN_ResNet50_VCOCO import ResNet50
    #     net = ResNet50(args.model)
    # elif args.model == 'iCAN_ResNet50_VCOCO_Early':
    #     from networks.iCAN_ResNet50_VCOCO_Early import ResNet50
    #     net = ResNet50(args.model)
    # else:
    iCAN_Early_flag = 0
    import os

    os.environ['DATASET'] = 'VCOCO1'
    from networks.HOI import HOI

    net = HOI(args.model)

    print('Pre-trained weights loaded.')

    # net = DisentanglingNet(model_name=args.model)
    image, blobs, image_id = obtain_data(Test_RCNN, prior_mask, Action_dic_inv,
                                         output_file, args.object_thres,
                                         args.human_thres, args.prior_flag)
    print('blobs:', blobs)
    print(image)

    net.set_ph(image,
               image_id,
               H_num=blobs['H_num'],
               spatial=blobs['sp'],
               H_boxes=blobs['H_boxes'],
예제 #6
0
    tb_dir = cfg.ROOT_DIR + '/logs/' + args.model + '/'

    # output directory where the models are saved
    output_dir = cfg.LOCAL_DATA + '/Weights/' + args.model + '/'
    if args.Restore_flag == 5:
        if os.path.exists(output_dir + 'checkpoint'):
            args.Restore_flag = -1
        elif args.model.__contains__('unique_weights'):
            args.Restore_flag = 6

    augment_type = get_augment_type(args.model)

    if args.model.__contains__('res101'):
        os.environ['DATASET'] = 'HICO_res101'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    else:
        from networks.HOI import HOI
        net = HOI(model_name=args.model)

    with_pose = False
    # if args.model.__contains__('pose'):
    #     with_pose = True

    coco = False
    zero_shot_type = get_zero_shot_type(args.model)
    large_neg_for_ho = False
    if args.model.endswith('_aug5_new') or args.model.endswith('_aug6_new'):
        large_neg_for_ho = True
    image, image_id, num_pos, Human_augmented, Object_augmented, action_HO, sp = obtain_data(
        Pos_augment=args.Pos_augment,
예제 #7
0
                                                                               'Noticeably, VCOCO only contains 26 verbs. We do not evaluate t2 and t3 carefully'
    # output directory where the logs are saved
    tb_dir = cfg.ROOT_DIR + '/logs/' + args.model + '/'

    # output directory where the models are saved
    output_dir = cfg.ROOT_DIR + '/Weights/' + args.model + '/'

    import os
    os.environ['DATASET'] = 'VCOCO'
    from networks.HOI import HOI
    augment_type = 0
    if args.model.__contains__('_aug5'):
        augment_type = 4
    elif args.model.__contains__('_aug6'):
        augment_type = 5
    network = HOI(args.model)
    image, image_id, num_pos, blobs = obtain_coco_data1(
        args.Pos_augment, args.Neg_select)

    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    if not os.path.exists(tb_dir):
        os.makedirs(tb_dir)

    tfconfig = tf.ConfigProto(device_count={"CPU": 16},
                              inter_op_parallelism_threads=8,
                              intra_op_parallelism_threads=8)
    # tfconfig = tf.ConfigProto()
    tfconfig.graph_options.optimizer_options.global_jit_level = tf.OptimizerOptions.ON_1
    tfconfig.gpu_options.allow_growth = True
예제 #8
0
    HICO_dir = cfg.LOCAL_DATA + '/Results/HICO/' + str(args.iteration) + '_' + args.model + '/'

    tfconfig = tf.ConfigProto(device_count={"CPU": 16},
                              inter_op_parallelism_threads=8,
                              intra_op_parallelism_threads=8,
                              allow_soft_placement=True)
    # init session
    # tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.allow_growth=True
    sess = tf.Session(config=tfconfig)


    if args.model.__contains__('res101'):
        os.environ['DATASET'] = 'HICO_res101'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    else:
        from networks.HOI import HOI
        net = HOI(model_name=args.model)


    if args.type == 'train':
        image, image_id, num_pos, Human_augmented, Object_augmented, action_HO, sp = obtain_data(
            Pos_augment=0,
            Neg_select=0,
            augment_type=-1,
            pattern_type=False)
        net.set_ph(image, image_id, num_pos, Human_augmented, Object_augmented, action_HO, sp)
    else:
        image, image_id, num_pos, Human_augmented, Object_augmented, action_HO, sp = obtain_test_data(
            Pos_augment=0,
예제 #9
0
    iCAN_Early_flag = 0
    import os
    os.environ['DATASET'] = 'VCOCO'
    from networks.HOI import HOI
    augment_type = 0
    if args.model.__contains__('_aug2'):
        augment_type = 1
    elif args.model.__contains__('_aug3'):
        augment_type = 2
    elif args.model.__contains__('_aug4'):
        augment_type = 3
    elif args.model.__contains__('_aug5'):
        augment_type = 4
    elif args.model.__contains__('_aug6'):
        augment_type = 5
    net = HOI(args.model)
    image, image_id, num_pos, blobs = obtain_coco_data(args.Pos_augment,
                                                       args.Neg_select)
    net.set_ph(image, image_id, num_pos, blobs['sp'], blobs['H_boxes'],
               blobs['O_boxes'], blobs['gt_class_H'], blobs['gt_class_HO'],
               blobs['gt_class_sp'], blobs['Mask_HO'], blobs['Mask_H'],
               blobs['Mask_sp'], blobs['gt_class_C'])

    train_net(net,
              Trainval_GT,
              Trainval_N,
              output_dir,
              tb_dir,
              args.Pos_augment,
              args.Neg_select,
              iCAN_Early_flag,
예제 #10
0
    HICO_dir = cfg.ROOT_DIR + '/Results/HICO/' + str(
        args.iteration) + '_' + args.model + '/'

    tfconfig = tf.ConfigProto(device_count={"CPU": 12},
                              inter_op_parallelism_threads=8,
                              intra_op_parallelism_threads=8,
                              allow_soft_placement=True)
    tfconfig.gpu_options.per_process_gpu_memory_fraction = 0.8
    sess = tf.Session(config=tfconfig)

    # Generate_HICO_detection(output_file, HICO_dir)
    if args.model.__contains__('VCOCO'):
        os.environ['DATASET'] = 'VCOCO1'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    elif args.model.__contains__('res101'):
        os.environ['DATASET'] = 'HICO_res101'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    else:
        from networks.HOI import HOI
        net = HOI(model_name=args.model)

    stride = 200

    test_type = 'default'
    test_type = args.test_type

    image, blobs, image_id = obtain_test_dataset_with_obj(
        args.object_thres,
예제 #11
0
    HICO_dir = cfg.LOCAL_DATA + '/Results/HICO/' + str(
        args.iteration) + '_' + args.model + '/'

    tfconfig = tf.ConfigProto(device_count={"CPU": 16},
                              inter_op_parallelism_threads=8,
                              intra_op_parallelism_threads=8,
                              allow_soft_placement=True)
    # init session
    # tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.per_process_gpu_memory_fraction = 0.1
    sess = tf.Session(config=tfconfig)

    if args.model.__contains__('res101'):
        os.environ['DATASET'] = 'HICO_res101'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    elif args.model.__contains__('VCOCO'):
        os.environ['DATASET'] = 'VCOCO1'
        from networks.HOI import HOI
        net = HOI(model_name=args.model)
    else:
        from networks.HOI import HOI
        net = HOI(model_name=args.model)

    if args.type == 'train':
        if not args.model.__contains__('VCOCO'):
            large_neg_for_ho = False
            image, image_id, num_pos, Human_augmented, Object_augmented, action_HO, sp = obtain_data(
                Pos_augment=0,
                Neg_select=0,
                augment_type=-1,