Update app.py
Browse files
app.py
CHANGED
@@ -13,8 +13,10 @@ tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
|
|
13 |
|
14 |
|
15 |
def calculate_ssim(img1, img2):
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
return ssim(img1_gray, img2_gray)
|
19 |
|
20 |
|
@@ -35,12 +37,9 @@ def calculate_text_similarity(text1, text2):
|
|
35 |
|
36 |
|
37 |
def calculate_color_similarity(img1, img2):
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
color_similarity = ssim(img1_lab, img2_lab, multichannel=True)
|
42 |
-
|
43 |
-
return color_similarity
|
44 |
|
45 |
|
46 |
def compare_trademarks(trademark1, trademark2):
|
|
|
13 |
|
14 |
|
15 |
def calculate_ssim(img1, img2):
|
16 |
+
img1_resized = cv2.resize(img1, (img2.shape[1], img2.shape[0]))
|
17 |
+
img2_resized = cv2.resize(img2, (img1.shape[1], img1.shape[0]))
|
18 |
+
img1_gray = cv2.cvtColor(img1_resized, cv2.COLOR_BGR2GRAY)
|
19 |
+
img2_gray = cv2.cvtColor(img2_resized, cv2.COLOR_BGR2GRAY)
|
20 |
return ssim(img1_gray, img2_gray)
|
21 |
|
22 |
|
|
|
37 |
|
38 |
|
39 |
def calculate_color_similarity(img1, img2):
|
40 |
+
hist1 = cv2.calcHist([img1], [0, 1, 2], None, [8, 8, 8], [0, 256, 0, 256, 0, 256])
|
41 |
+
hist2 = cv2.calcHist([img2], [0, 1, 2], None, [8, 8, 8], [0, 256, 0, 256, 0, 256])
|
42 |
+
return cv2.compareHist(hist1, hist2, cv2.HISTCMP_CORREL)
|
|
|
|
|
|
|
43 |
|
44 |
|
45 |
def compare_trademarks(trademark1, trademark2):
|