omar87 commited on
Commit
3a834c5
·
1 Parent(s): e850d8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -10,12 +10,13 @@ def calculate_similarity(img1, img2):
10
  return ssim(img1, img2)
11
 
12
  # Function to compute similarity scores for all images
13
- def compute_similarity(target_image, image_list):
14
- scores = []
15
- for image in image_list:
16
- similarity_score = calculate_similarity(target_image, image)
17
- scores.append(similarity_score)
18
- return scores
 
19
 
20
  # Function to handle the Gradio interface
21
  def image_similarity(target_image, image_list):
 
10
  return ssim(img1, img2)
11
 
12
  # Function to compute similarity scores for all images
13
+ def calculate_similarity(img1, img2):
14
+ if len(img1.shape) == 2:
15
+ img1 = cv2.cvtColor(img1, cv2.COLOR_GRAY2RGB)
16
+ if len(img2.shape) == 2:
17
+ img2 = cv2.cvtColor(img2, cv2.COLOR_GRAY2RGB)
18
+ return ssim(img1, img2)
19
+
20
 
21
  # Function to handle the Gradio interface
22
  def image_similarity(target_image, image_list):