Created
February 16, 2016 01:09
-
-
Save venuktan/a112cfa264aeb02a7e0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from nearpy import Engine | |
from nearpy.hashes import RandomBinaryProjections, HashPermutationMapper, HashPermutations | |
from nearpy.distances import CosineDistance | |
from nearpy.filters.nearestfilter import NearestFilter | |
from nearpy.storage import RedisStorage | |
import glob | |
import time | |
from redis import Redis | |
redis_storage = RedisStorage( | |
Redis(host='similar-images-index.i4cyv7.0001.use1.cache.amazonaws.com', | |
port=6379, db=0)) | |
# Create a random binary hash with 10 bits | |
hashes = HashPermutations('permut2') | |
# Create binary hash as child hash | |
rbp_perm = RandomBinaryProjections('rbp_perm', 14) | |
rbp_conf = {'num_permutation':50,'beam_size':10,'num_neighbour':100} | |
# Add rbp as child hash of permutations hash | |
hashes.add_child_hash(rbp_perm, rbp_conf) | |
# for k in range(5): | |
# hashes.append(HashPermutationMapper ('rbp_%d' % k, 10)) | |
# Create engine | |
dimension =2048 | |
engine = Engine(dimension, lshashes=[hashes], | |
vector_filters = [NearestFilter(10)], | |
distance=CosineDistance(), | |
storage=redis_storage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment