I change images to hash values and try to classify images with similar hash values into the same group.
so for example.
import imagehash
# img1, img2, img3 are same images
img1_hash = imagehash.average_hash(Image.open('data/image1.jpg'))
img2_hash = imagehash.average_hash(Image.open('data/image2.jpg'))
img3_hash = imagehash.average_hash(Image.open('data/image3.jpg'))
img4_hash = imagehash.average_hash(Image.open('data/image4.jpg'))
print(img1_has, img2_hash, img3_hash, img4_hash)
>>> 81c38181bf8781ff, 81838181bf8781ff, 81838181bf8781ff, ff0000ff3f00e7ff
hash_lst = [['img1', img1_hash], ['img2', img2_hash], ['img3', img3_hash], ['img4', img4_hash]]
##
Grouping Code
##
outputs:
[['img1', 'img2', 'img3'], ['img4']]
Is there a grouping code to classify effectively?
Thank you