Ajay98 commited on
Commit
bcda3e2
·
verified ·
1 Parent(s): e04eb02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -40
app.py CHANGED
@@ -5,47 +5,14 @@ import numpy as np
5
  staff_folder_path = r"C:\Users\nikit\OneDrive\Desktop\Test1" # Replace with the correct path
6
  unknown_folder_path = r"C:\Users\nikit\OneDrive\Desktop\Test2" # Replace with the correct path
7
 
 
 
 
8
 
9
- def compare_images(image1, image2):
10
- Read the images
11
- ##img1 = cv2.imread(staff_folder_path)
12
- img2 = cv2.imread(unknown_folder_path)
13
-
14
- # Check if both images are loaded properly
15
- if img1 is None or img2 is None:
16
- return False
17
-
18
- # Resize images to the same size
19
- img1 = cv2.resize(img1, (100, 100))
20
- img2 = cv2.resize(img2, (100, 100))
21
-
22
- # Convert images to grayscale
23
- gray1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
24
- gray2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
25
 
26
- # Calculate the Structural Similarity Index (SSI)
27
- score, _ = cv2.compare_ssim(gray1, gray2, full=True)
28
-
29
- # You can adjust the threshold based on your needs
30
- return score >= 0.9 # Threshold for similarity
31
 
32
- def compare_folders(staff_folder, unknown_folder):
33
- for staff_image in os.listdir(staff_folder):
34
- staff_image_path = os.path.join(staff_folder, staff_image)
35
- found_match = False
36
-
37
- for unknown_image in os.listdir(unknown_folder):
38
- unknown_image_path = os.path.join(unknown_folder, unknown_image)
39
-
40
- if compare_images(staff_image_path, unknown_image_path):
41
- print(f"Match found: {staff_image} matches {unknown_image} (Staff)")
42
- found_match = True
43
- break
44
-
45
- if not found_match:
46
- print(f"No match found for {staff_image} (Unknown)")
47
 
48
- # Usage
49
- staff_folder_path = 'path/to/staff/images'
50
- unknown_folder_path = 'path/to/unknown/images'
51
- compare_folders(staff_folder_path, unknown_folder_path)###
 
5
  staff_folder_path = r"C:\Users\nikit\OneDrive\Desktop\Test1" # Replace with the correct path
6
  unknown_folder_path = r"C:\Users\nikit\OneDrive\Desktop\Test2" # Replace with the correct path
7
 
8
+ print(f"Staff folder path: {staff_folder_path}")
9
+ print(f"Unknown folder path: {unknown_folder_path}")
10
+ import os
11
 
12
+ if os.path.exists(path):
13
+ print("Path exists!")
14
+ else:
15
+ print("Path does not exist.")
 
 
 
 
 
 
 
 
 
 
 
 
16
 
 
 
 
 
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18