Refactor changed are done
This commit is contained in:
@@ -20,14 +20,14 @@ def hash_hex_to_hash_array(hash_hex) -> NDArray:
|
||||
# convert hash string in hex to hash values of 0 or 1
|
||||
hash_str = int(hash_hex, 16)
|
||||
array_str = bin(hash_str)[2:]
|
||||
return np.array([i for i in array_str], dtype=np.float32)
|
||||
return np.array(list(array_str), dtype=np.float32)
|
||||
|
||||
|
||||
def get_duplicates_cache(album: str) -> dict:
|
||||
output = {}
|
||||
for photo in col_photos.find({"album": album}):
|
||||
output[photo["filename"]] = [photo["_id"].__str__(), photo["hash"]]
|
||||
return output
|
||||
return {
|
||||
photo["filename"]: [photo["_id"].__str__(), photo["hash"]]
|
||||
for photo in col_photos.find({"album": album})
|
||||
}
|
||||
|
||||
|
||||
async def get_phash(filepath: Union[str, Path]) -> str:
|
||||
@@ -55,7 +55,7 @@ async def get_phash(filepath: Union[str, Path]) -> str:
|
||||
async def get_duplicates(hash_string: str, album: str) -> list:
|
||||
duplicates = []
|
||||
cache = get_duplicates_cache(album)
|
||||
for image_name, image_value in cache.items():
|
||||
for image_name, image_object in cache.items():
|
||||
try:
|
||||
distance = spatial.distance.hamming(
|
||||
hash_hex_to_hash_array(cache[image_name][1]),
|
||||
|
Reference in New Issue
Block a user