File size: 1,147 Bytes
1a43383
b12bd2d
 
 
 
21c2218
7559e30
86e69fa
0d2d614
b12bd2d
 
 
623fe69
b12bd2d
0d2d614
f4eb306
b12bd2d
0d2d614
b12bd2d
0d2d614
 
b12bd2d
27b7cb5
b12bd2d
690ada3
0d2d614
690ada3
b12bd2d
 
690ada3
 
b12bd2d
 
690ada3
 
b12bd2d
a7129dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr
import cv2
import numpy as np
from skimage.metrics import structural_similarity as ssim
from PIL import Image
import io

# Function to calculate SSIM between two images
def calculate_ssim(img1, img2):
    img1_gray = Image.open(io.BytesIO(img1)).convert("L")
    img2_gray = Image.open(io.BytesIO(img2)).convert("L")
    return ssim(np.array(img1_gray), np.array(img2_gray))

# Function to compare two trademarks
def compare_trademarks(trademark1, trademark2):
    ssim_score = calculate_ssim(trademark1, trademark2)
    return ssim_score

# Function to handle the Gradio interface
def prevent_trademark_conflict(trademark1, trademark2):
    similarity_score = compare_trademarks(trademark1, trademark2)
    return similarity_score

# Prepare Gradio interface
iface = gr.Interface(
    fn=prevent_trademark_conflict,
    inputs=[
        gr.inputs.Image(type="file", label="Trademark Image 1"),
        gr.inputs.Image(type="file", label="Trademark Image 2")
    ],
    outputs="text",
    title="Trademark Similarity",
    description="Compare two trademarks to check for similarity."
)

# Launch the interface
iface.launch()