Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import numpy as np
|
|
| 4 |
from skimage.metrics import structural_similarity as ssim
|
| 5 |
from transformers import BertForSequenceClassification, BertTokenizer
|
| 6 |
import torch
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
# Load pre-trained model and tokenizer
|
|
@@ -43,8 +44,8 @@ def calculate_color_similarity(img1, img2):
|
|
| 43 |
|
| 44 |
|
| 45 |
def compare_trademarks(trademark1, trademark2):
|
| 46 |
-
img1 =
|
| 47 |
-
img2 =
|
| 48 |
|
| 49 |
ssim_score = calculate_ssim(img1, img2)
|
| 50 |
|
|
@@ -67,8 +68,8 @@ def prevent_trademark_conflict(trademark1, trademark2):
|
|
| 67 |
trademark_comparison_interface = gr.Interface(
|
| 68 |
fn=prevent_trademark_conflict,
|
| 69 |
inputs=[
|
| 70 |
-
gr.inputs.Image(type="
|
| 71 |
-
gr.inputs.Image(type="
|
| 72 |
],
|
| 73 |
outputs="text",
|
| 74 |
title="Trademark Comparison",
|
|
|
|
| 4 |
from skimage.metrics import structural_similarity as ssim
|
| 5 |
from transformers import BertForSequenceClassification, BertTokenizer
|
| 6 |
import torch
|
| 7 |
+
from PIL import Image
|
| 8 |
|
| 9 |
|
| 10 |
# Load pre-trained model and tokenizer
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
def compare_trademarks(trademark1, trademark2):
|
| 47 |
+
img1 = np.array(trademark1)
|
| 48 |
+
img2 = np.array(trademark2)
|
| 49 |
|
| 50 |
ssim_score = calculate_ssim(img1, img2)
|
| 51 |
|
|
|
|
| 68 |
trademark_comparison_interface = gr.Interface(
|
| 69 |
fn=prevent_trademark_conflict,
|
| 70 |
inputs=[
|
| 71 |
+
gr.inputs.Image(type="pil", label="Trademark Image 1"),
|
| 72 |
+
gr.inputs.Image(type="pil", label="Trademark Image 2"),
|
| 73 |
],
|
| 74 |
outputs="text",
|
| 75 |
title="Trademark Comparison",
|