Not a Dup words...

main
Robert 8 months ago
parent 1b6a199457
commit 4e3a030dc2
  1. 20
      dedup.py

@ -42,7 +42,7 @@ signal.signal(signal.SIGINT, exit_handler)
def exit_timer(level): def exit_timer(level):
end = time.perf_counter() end = time.perf_counter()
print(f"Execution took {end - start:.4f} seconds") print(f"Execution took {end - start:.4f} seconds")
exit(level) exit(level)
class Timer: class Timer:
@ -74,7 +74,7 @@ class Timer:
def print_result(self): def print_result(self):
elapsed = self.elapsed() elapsed = self.elapsed()
print(f"{self.name}: {elapsed:.6f} seconds") print(f"{self.name}: {elapsed:.6f} seconds")
def align_with_downscaling(img1, img2, downscale_factor=4, try_common_rotations=True): def align_with_downscaling(img1, img2, downscale_factor=4, try_common_rotations=True):
""" """
@ -442,7 +442,7 @@ if __name__ == "__main__":
if (hash1 == hash2): if (hash1 == hash2):
print("xxHash found duplicates") print("xxHash found duplicates")
print("✅ Perfect match - images are identical") print("❌ Perfect match - images are identical - Duplicate Found!")
print("No transformation needed") print("No transformation needed")
exit_timer(1) exit_timer(1)
else: else:
@ -456,14 +456,16 @@ if __name__ == "__main__":
w, h = get_image_dimensions_cv(large_img1) w, h = get_image_dimensions_cv(large_img1)
w2, h2 = get_image_dimensions_cv(large_img2) w2, h2 = get_image_dimensions_cv(large_img2)
if w == None or w2 == None or h == None or h2 == None: if w == None or w2 == None or h == None or h2 == None:
print("Aborting...Invalid Image!") print("Aborting...Invalid Image!")
exit_timer(8) exit_timer(8)
if w != w2 and w != h2: if w != w2 and w != h2:
print("Diffent Resolutions") print("Diffent Resolutions")
print("👌Not a Duplicate")
exit_timer(0) exit_timer(0)
if h != h2 and h != w2: if h != h2 and h != w2:
print("Diffent Resolutions") print("Diffent Resolutions")
print("👌Not a Duplicate")
exit_timer(0) exit_timer(0)
print("Done loading images...") print("Done loading images...")
@ -491,10 +493,10 @@ if __name__ == "__main__":
is_score = "" is_score = ""
if matrix_score == 1.0 and is_score != "scores": if matrix_score == 1.0 and is_score != "scores":
print("✅ Perfect Matrix score, should be identical") print("❌ Perfect match score, images should be identical - Duplicate Found!")
exit_timer(1) exit_timer(1)
if matrix_score < 0.3 and is_score != "scores": if matrix_score < 0.3 and is_score != "scores":
print("❌ Significant transformation required") print("👌Not a Duplicate, best guess!")
exit_timer(0) exit_timer(0)
if is_score == "scores": if is_score == "scores":
score = find_duplicate_with_rotation(large_img1, aligned) score = find_duplicate_with_rotation(large_img1, aligned)
@ -505,14 +507,14 @@ if __name__ == "__main__":
# Check for perfect alignment # Check for perfect alignment
if matrix_score == 1.0 and decomposed_score == 1.0 and combined_score == 1.0: if matrix_score == 1.0 and decomposed_score == 1.0 and combined_score == 1.0:
print("✅ Perfect match - images are identical") print("❌ Perfect match - images are identical - Duplicate Found!")
print("No transformation needed") print("No transformation needed")
exit_code = 1 exit_code = 1
elif matrix_score > 0.9 and decomposed_score > 0.9 and combined_score > 0.7: elif matrix_score > 0.9 and decomposed_score > 0.9 and combined_score > 0.7:
print(" Near-perfect alignment - minor differences detected") print(" Near-perfect alignment - minor differences detected")
exit_code = 2 exit_code = 2
else: else:
print("❌ Significant transformation required") print("👌Not a Duplicate")
exit_code = 0 exit_code = 0
print(f"Matrix deviation score: {matrix_score:.4f}") print(f"Matrix deviation score: {matrix_score:.4f}")

Loading…
Cancel
Save