Fixed path error
This commit is contained in:
parent
5cc10367b2
commit
b003712358
@ -1,3 +1,6 @@
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from numpy.typing import NDArray
|
||||
@ -27,8 +30,8 @@ def get_duplicates_cache(album: str) -> dict:
|
||||
return output
|
||||
|
||||
|
||||
async def get_phash(filepath: str) -> str:
|
||||
img = cv2.imread(filepath)
|
||||
async def get_phash(filepath: Union[str, Path]) -> str:
|
||||
img = cv2.imread(str(filepath))
|
||||
# resize image and convert to gray scale
|
||||
img = cv2.resize(img, (64, 64))
|
||||
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
@ -49,14 +52,14 @@ async def get_phash(filepath: str) -> str:
|
||||
return hash_array_to_hash_hex(dct_block.flatten())
|
||||
|
||||
|
||||
async def get_duplicates(hash: str, album: str) -> list:
|
||||
async def get_duplicates(hash_string: str, album: str) -> list:
|
||||
duplicates = []
|
||||
cache = get_duplicates_cache(album)
|
||||
for image_name in cache.keys():
|
||||
for image_name, image_value in cache.items():
|
||||
try:
|
||||
distance = spatial.distance.hamming(
|
||||
hash_hex_to_hash_array(cache[image_name][1]),
|
||||
hash_hex_to_hash_array(hash),
|
||||
hash_hex_to_hash_array(hash_string),
|
||||
)
|
||||
except ValueError:
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user