omar87 commited on
Commit
404fc64
·
1 Parent(s): 746d2ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -7,7 +7,8 @@ def calculate_similarity(img1, img2):
7
  img1 = cv2.cvtColor(img1, cv2.COLOR_GRAY2RGB)
8
  if len(img2.shape) == 2:
9
  img2 = cv2.cvtColor(img2, cv2.COLOR_GRAY2RGB)
10
- diff = cv2.absdiff(img1, img2)
 
11
  similarity_score = np.mean(diff)
12
  return similarity_score
13
 
@@ -29,4 +30,4 @@ iface = gr.Interface(
29
  description="Upload two images to compute their similarity."
30
  )
31
 
32
- iface.launch()
 
7
  img1 = cv2.cvtColor(img1, cv2.COLOR_GRAY2RGB)
8
  if len(img2.shape) == 2:
9
  img2 = cv2.cvtColor(img2, cv2.COLOR_GRAY2RGB)
10
+ img1_resized = cv2.resize(img1, (img2.shape[1], img2.shape[0]))
11
+ diff = cv2.absdiff(img1_resized, img2)
12
  similarity_score = np.mean(diff)
13
  return similarity_score
14
 
 
30
  description="Upload two images to compute their similarity."
31
  )
32
 
33
+ iface.launch(share=True)