#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'ipetrash'
# SOURCE: https://github.com/JohannesBuchner/imagehash
from glob import glob
import itertools
# pip install imagehash
import imagehash
# pip install pillow
from PIL import Image
file_names = glob(r'C:\Users\Diman\Desktop\test\img\**\*.png', recursive=True)
print(f'Files: {len(file_names)}')
img_by_hash = dict()
for file_name in file_names:
try:
hash_img = imagehash.phash(Image.open(file_name))
except Exception as e:
print(f'Problem: {e} with "{file_name}"')
continue
#print(hash_img)
img_by_hash[file_name] = hash_img
print('Find similar images')
for img_1, img_2 in itertools.combinations(img_by_hash.items(), 2):
file_name_1, hash_img_1 = img_1
file_name_2, hash_img_2 = img_2
score = hash_img_1 - hash_img_2
if score > 10:
continue
print(f'Score: {score:2}. Similar images: "{file_name_1}" and "{file_name_2}"')
print('ok')
input()
500 Internal Server Error
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
ValueError: Tensor("total:0", shape=(), dtype=resource) must be from the same graph as Tensor("Placeholder:0", shape=(), dtype=float32)
`hash`='$row[1]- это уникальный ключ клиента
Боюсь по вашему методу будут затронуты те строки, которые не попадут в массив