question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Version 3 not in pypi repo

See original GitHub issue

Not sure if this was the right place, but I want to upgrade my imagehash version and doing pip install imagehash --upgrade still gives me the 2.2 version, presumably because the pypi page hasn’t been updated with v3.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
JohannesBuchnercommented, Sep 20, 2016

numpy.flatten makes a 1d array out of the 2d array (matrix) where the hash is stored. != compares element-wise if the things are the same, numpy.sum() adds the number of differences, which gives the Hamming distance.

What I am suggesting is:

I suspect you are doing something like this now:

diff, closestdbHash = min([(dbHash - testhash, dbHash) for dbHash in db])

which does the same as

diff, closestdbHash = min([((dbHash.hash != testhash.hash).sum(), dbHash) for dbHash in db])

You can store your DB as a 2d matrix:

arr = []
for dbHash in db:
    arr.append(dbHash.hash.flatten())
arr = numpy.array(arr)

Then you can do the comparison against all at the same time:

binarydiff = arr != testhash.hash.reshape((1,-1))
hammingdiff = binarydiff.sum(axis=1)
closestdbHash_i = numpy.argmin(hammingdiff)
closestdbHash = db[closestdbHash_i]

This will be very, very fast.

0reactions
mynameisvinncommented, Dec 25, 2016

@PAK90 @JohannesBuchner ive been using approximate nearest neighbor to loop through a collection of hashes. annoy was developed by spotify to find similar users/songs for their recommender system.

https://github.com/spotify/annoy

hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nexus pypi repository "Could not find a version that satisfies ...
The url of the repository is "http://localhost:8081/repository/pypi/". Then i used pip to install packages using nexus repository, in $HOME/.
Read more >
PyPI · The Python Package Index
The Python Package Index (PyPI) is a repository of software for the Python programming language. PyPI helps you find and install software developed...
Read more >
Error with pip install from PyPI in self hosted Gitlab - General
Hello :slight_smile:, so far I am quite happy with our self hosted Gitlab but I cannot pip install the release of a library...
Read more >
[NEXUS-19303] PyPi hosted repository doesn't update index ...
When uploading a new version of an existing component the deleteIndex function does not delete the file. This causes the file to remain...
Read more >
Unable to install PyPi package - Sonatype Support
This article is for troubleshooting issues with installing PyPi packages (using pip install <package> -v) using a Nexus Repository Manager 3.x.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found