Beispiel #1
0
def load_vidor_dataset():
    if not os.path.exists('dataset/vidor-dataset.pkl'):
        dataset = VidOR(anno_path, video_path, ['training', 'validation'], low_memory=True)
        with open('dataset/vidor-dataset.pkl','wb') as file:
            pickle.dump(dataset,file)
    else:
        with open('dataset/vidor-dataset.pkl','rb') as file:
            dataset = pickle.load(file)
    return dataset
Beispiel #2
0
def load_vidor_dataset():
    dataset_path = '/home/wluo/vidor-dataset'
    anno_path = os.path.join(dataset_path, 'annotation')
    video_path = os.path.join(dataset_path, 'video')
    frame_path = os.path.join(dataset_path, 'frame')
    if not os.path.exists('dataset/vidor-dataset.pkl'):
        dataset = VidOR(anno_path,
                        video_path, ['training', 'validation'],
                        low_memory=True)
        with open('dataset/vidor-dataset.pkl', 'wb') as file:
            pickle.dump(dataset, file)
    else:
        with open('dataset/vidor-dataset.pkl', 'rb') as file:
            dataset = pickle.load(file)
    return dataset
Beispiel #3
0
    args = parser.parse_args()

    if args.dataset=='imagenet-vidvrd':
        if args.split=='testing':
            args.split = 'test'
        else:
            print('[warning] there is no validation set in ImageNet-VidVRD dataset')
        if args.task=='relation':
            # load train set for zero-shot evaluation
            dataset = ImagenetVidVRD('../vidvrd-dataset', '../vidvrd-dataset/videos', ['train', args.split])
        else:
            dataset = ImagenetVidVRD('../vidvrd-dataset', '../vidvrd-dataset/videos', [args.split])
    elif args.dataset=='vidor':
        if args.task=='relation':
            # load train set for zero-shot evaluation
            dataset = VidOR('../vidor-dataset/annotation', '../vidor-dataset/video', ['training', args.split], low_memory=True)
        else:
            dataset = VidOR('../vidor-dataset/annotation', '../vidor-dataset/video', [args.split], low_memory=True)
    else:
        raise Exception('Unknown dataset {}'.format(args.dataset))

    print('Loading prediction from {}'.format(args.prediction))
    with lzma.open(args.prediction, 'rt') as fin:
        pred = json.load(fin)
    print('Number of videos in prediction: {}'.format(len(pred['results'])))

    if args.task=='object':
        evaluate_object(dataset, args.split, pred['results'])
    elif args.task=='relation':
        evaluate_relation(dataset, args.split, pred['results'])
Beispiel #4
0
    parser.add_argument('--dataset',
                        choices=['vidvrd', 'vidor'],
                        help='the dataset name')
    parser.add_argument('--train',
                        action="store_true",
                        default=False,
                        help='Train model')
    parser.add_argument('--detect',
                        action="store_true",
                        default=False,
                        help='Detect video visual relation')
    args = parser.parse_args()
    if args.dataset == 'vidvrd':
        dataset = ImagenetVidVRD('./vidvrd-dataset', './vidvrd-dataset/videos',
                                 ['train', 'test'])

    elif args.dataset == 'vidor':
        dataset = VidOR('./vidor-dataset/annotation', './vidor-dataset/video',
                        ['training', 'validation'])

    if args.load_feature or args.train or args.detect:
        if args.load_feature:
            load_object_trajectory_proposal()
            load_relation_feature()
        if args.train:
            train()
        if args.detect:
            detect()
    else:
        parser.print_help()
Beispiel #5
0
    parser.add_argument('prediction', type=str, help='Prediction json file')
    parser.add_argument("--object",
                        action="store_true",
                        help="whether to evaluate video objects")
    parser.add_argument("--action",
                        action="store_true",
                        help="whether to evaluate actions")
    parser.add_argument("--relation",
                        action="store_true",
                        help="whether to evaluate visual relations")
    args = parser.parse_args()

    if args.dataset == 'vidvrd':
        dataset = VidVRD('../vidvrd-dataset', '../vidvrd-dataset/videos',
                         [args.split])
    elif args.dataset == 'vidor':
        dataset = VidOR('../vidor/annotation',
                        '../vidor/vidor', [args.split],
                        low_memory=True)
    else:
        raise Exception('Unknown dataset {}'.format(args.dataset))

    with open(args.prediction, 'r') as fin:
        prediction_json = json.load(fin)

    if args.object:
        evaluate_object(dataset, args.split, prediction_json)
    if args.action:
        evaluate_action(dataset, args.split, prediction_json)
    if args.relation:
        evaluate_relation(dataset, args.split, prediction_json)