Skip to content

lannguyen0910/image-deep-hash

Repository files navigation

Image Deep Hash

Information Integrity Checking is one of the important uses of hash functions. However, current hash functions such as SHA, MD, etc. only tell us the integrity of the file, but do not tell us how much the information has changed.


For an image that only needs to be 1 pixel different, the hash results will be completely different. In some cases like loading a 60fps video and only 1 frame is 1 pixel wrong, reloading is too expensive. We overcome that problem by extracting features of the image to evaluate the difference between the downloaded image and the original image and then make a decision whether it is necessary to reload or not. However, the solution also has limitations in having high time and space complexity.

🌟 Run on localhost (require CUDA)

  • Clone the repo
git clone https://github.com/lannguyen0910/image-deep-hash
cd image-deep-hash/
  • Install dependencies
pip install -r requirements.txt
  • Start the app
python app.py --host=localhost:3000
  • Or use this command to clear cache after running.
run.bat

🌟 Run using Google Colab

Open notebook and follow the instructions Notebook

🌟 Deep Hash

Hash an image and return to a hash sequence which its hex length is modifiable. Go to hash_tutorial and hash_module for more information

from src import ImageDeepHash

m = ImageDeepHash.ImageDeepHash()
m.hash("ILSVRC2012_val_00005002.jpeg")
print(m.digest())
print(m.hexdigest())
m.plot()

m.reset()
m.hash("ILSVRC2012_val_00005002_noise.jpeg")
print(m.digest())
print(m.hexdigest())
m.plot()

Run on web:

🌟 Deep Compare

Hash 2 images and evaluate the difference using some appropriate metrics for comparision. Go to compare_tutorial and compare_module for more information

from src import ImageDeepCompare

m = ImageDeepCompare.ImageDeepCompare()
print("Distance:", m.compare("ILSVRC2012_val_00005002.jpeg", "ILSVRC2012_val_00005002_noise.jpeg", "euclidean"))
m.plot()

Run on web:


Compare example 1 result