21 lines
526 B
Python
21 lines
526 B
Python
from PIL import Image
|
|
import imagehash
|
|
import os
|
|
|
|
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
|
img1 = imagehash.phash(Image.open("u1.png"))
|
|
img2 = imagehash.phash(Image.open("u2.png"))
|
|
def check_image(img1, img2):
|
|
print(img1)
|
|
print(img2)
|
|
distance = img1 - img2
|
|
print(distance)
|
|
if distance > 10: # typical threshold ~5-12 depending on use case
|
|
print("→ pHash says different → Early exit")
|
|
else:
|
|
print("→ pHash passed → Proceeding to deep embeddings")
|
|
|
|
|
|
check_image(img1, img2)
|