Example #1
0
def main():
    selector = FPSReductionKS(n=3)
    extractors = [
        ColorLayoutFE(),
        AutoEncoderFE.load_autoencoder(model_name='../features/model'),
    ]

    for extractor in extractors:
        tags, features = group_features(selector=selector, extractor=extractor)

        x = range(features.shape[1])
        mean = np.mean(features, axis=0)
        std = np.std(features, axis=0)
        mins = np.min(features, axis=0)
        maxs = np.max(features, axis=0)

        plt.figure()
        plt.title(f'{selector.name()} - {extractor.name()}')

        plt.errorbar(x, mean, std, fmt='.b', ecolor='r', capsize=3)

        plt.plot(x, maxs, 'g')
        plt.plot(x, mins, 'y')
        plt.legend([
            'max',
            'min',
        ])

        plt.xlabel('features')
        plt.ylabel('value')

    plt.show()
    return
def main():
    selectors = [
        FPSReductionKS(n=3),
        MaxHistDiffKS(frames_per_window=1),
    ]
    extractors = [
        ColorLayoutFE(),
        AutoEncoderFE(dummy=True),
    ]
    indexes = [
        LinearIndex(dummy=True),
        KDTreeIndex(dummy=True, trees=5),
        SGHIndex(dummy=True, projections=10),
    ]
    lshs = [
        LSHIndex(dummy=True, projections=5, tables=10),  # color layout
        LSHIndex(dummy=True, projections=3, tables=10),  # auto encoder
    ]

    for selector in selectors:
        read_selection_log(selector, extractors)

    for extractor in extractors:
        read_extraction_log(extractor, selectors)

    for index in indexes:
        read_index_logs(selectors, extractors, index)

    for i in range(len(lshs)):
        read_index_logs(selectors, [extractors[i]], lshs[i])

    read_detection_log()
    return
def main():
    selectors = [
        FPSReductionKS(n=3),
        # MaxHistDiffKS(frames_per_window=1),
    ]
    extractors = [
        ColorLayoutFE(),
        AutoEncoderFE(dummy=True, model_name='model'),
    ]
    indexes = [
        # LinearIndex(dummy=True, k=100),
        KDTreeIndex(dummy=True, trees=5, k=100),
        # SGHIndex(dummy=True, projections=14, tables=2, k=100),
        # LSHIndex(dummy=True, projections=14, k=100),
    ]

    for selector in selectors:
        for extractor in extractors:
            for index in indexes:
                find_copies(
                    video_name='385',
                    selector=selector,
                    extractor=extractor,
                    index=index,
                )
    return
def main():
    videos = ['417', '143', '215', '385', '178', '119-120', ]

    selectors = [
        FPSReductionKS(n=3),
        MaxHistDiffKS(frames_per_window=1),
    ]
    extractors = [
        ColorLayoutFE(),
        AutoEncoderFE(dummy=True),
    ]

    indexes = [
        LinearIndex(dummy=True),
        KDTreeIndex(dummy=True, trees=5),
        SGHIndex(dummy=True, projections=10),
        LSHIndex(dummy=True, projections=5, tables=10),  # color layout
        LSHIndex(dummy=True, projections=3, tables=10),  # auto encoder
    ]

    datasets = [
        (selectors[0], extractors[0], indexes[0],),  # linear
        # (selectors[0], extractors[0], indexes[1],),  # kdtree
        # (selectors[0], extractors[0], indexes[2],),  # sgh
        # (selectors[0], extractors[0], indexes[3],),  # lsh

        # (selectors[0], extractors[1], indexes[0],),  # linear
        # (selectors[0], extractors[1], indexes[1],),  # kdtree
        # (selectors[0], extractors[1], indexes[2],),  # sgh
        # (selectors[0], extractors[1], indexes[4],),  # lsh

        # (selectors[1], extractors[0], indexes[1],),  # kdtree
        # (selectors[1], extractors[0], indexes[2],),  # sgh
        # (selectors[1], extractors[0], indexes[3],),  # lsh

        # (selectors[1], extractors[1], indexes[1],),  # kdtree
        # (selectors[1], extractors[1], indexes[2],),  # sgh
        # (selectors[1], extractors[1], indexes[4],),  # lsh
    ]

    for video in videos:
        for selector, extractor, index in datasets:
            evaluate_duplicates(
                video_name=video,
                selector=selector,
                extractor=extractor,
                index=index,
            )
    return
Example #5
0
def main():
    selectors = [
        FPSReductionKS(n=3),
        MaxHistDiffKS(frames_per_window=1),
    ]
    extractors = [
        ColorLayoutFE(),
        AutoEncoderFE.load_autoencoder(model_name='features/model'),
    ]

    for selector in selectors:
        for extractor in extractors:
            extract_features_videos(selector=selector, extractor=extractor, force=True)

    return
def main():
    max_missing_streak = 6
    min_duration = 5
    max_offset = 2

    videos = ['119-120', '143', '178', '215', '385', '417', ]

    selectors = [
        # FPSReductionKS(n=3),
        MaxHistDiffKS(frames_per_window=1),
    ]
    extractors = [
        ColorLayoutFE(),
        AutoEncoderFE(dummy=True),
    ]

    indexes = [
        LinearIndex(dummy=True),
        KDTreeIndex(dummy=True, trees=5),
        SGHIndex(dummy=True, projections=10),
        # LSHIndex(dummy=True, projections=5, tables=10),  # color layout
        # LSHIndex(dummy=True, projections=3, tables=10),  # auto encoder
    ]

    for selector in selectors:
        for extractor in extractors:
            for index in indexes:
                for video_name in videos:
                    find_copies(
                        video_name=video_name,
                        selector=selector,
                        extractor=extractor,
                        index=index,
                        max_missing_streak=max_missing_streak,
                        min_duration=min_duration,
                        max_offset=max_offset,
                        force=True,
                    )
    return
Example #7
0
def main():
    np.random.seed(1209)
    videos = [
        '119-120',
        '143',
        '178',
        '215',
        '385',
        '417',
    ]  # ['190', '227', ]
    k = 100

    selectors = [
        MaxHistDiffKS(frames_per_window=1),
        FPSReductionKS(n=3),
    ]
    extractors = [
        ColorLayoutFE(),
        # AutoEncoderFE.load_autoencoder(model_name='features/model'),
    ]
    indexes = [
        [LinearIndex, {}],
        [KDTreeIndex, {
            'trees': 5,
            'checks': 1000
        }],
        [SGHIndex, {
            'projections': 10,
            'training_split': 0.3
        }],
        [LSHIndex, {
            'projections': 5,
            'tables': 10,
            'bin_width': 20
        }],  # for color layout
        # [LSHIndex, {'projections': 3, 'tables': 10, 'bin_width': 20}],  # for autoencoder
    ]

    for selector in selectors:
        for extractor in extractors:
            print('\n')
            all_tags, all_features = group_features(selector=selector,
                                                    extractor=extractor)
            print(f'loaded {all_features.shape[0]:,} features')

            for index_class, kwargs in indexes:
                print(f'\nstarting index construction')
                index = index_class(data=all_features,
                                    labels=all_tags,
                                    k=k,
                                    **kwargs)
                print(
                    f'{index.name()} construction took {index.build_time:.1f} seconds\n'
                )

                try:
                    index.engine.analize_storage()
                except:
                    pass

                neighbours_path = get_neighbours_dir(selector=selector,
                                                     extractor=extractor,
                                                     index=index)
                if not os.path.isdir(neighbours_path):
                    os.makedirs(neighbours_path)

                log_path = f'{neighbours_path}/constructions.txt'
                log_persistent(
                    f'{index.name()}\t{index.build_time:.2f}\t{all_features.shape[0]}\n',
                    log_path=log_path)

                for video_name in videos:
                    nearest_neighbours(video_name=video_name,
                                       selector=selector,
                                       extractor=extractor,
                                       index=index,
                                       analize=True,
                                       force=True)
    return