Spaces:
Sleeping
Sleeping
aliasgerovs
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -23,14 +23,14 @@ def compare_images(image1, image2):
|
|
23 |
|
24 |
# Compute cosine similarity between features
|
25 |
similarity = np.dot(features1, features2.T)
|
26 |
-
similarity
|
27 |
return {'Similarity': float(similarity)}
|
28 |
|
29 |
# Setup Gradio interface
|
30 |
iface = gr.Interface(
|
31 |
fn=compare_images,
|
32 |
-
inputs=[gr.
|
33 |
-
outputs=
|
34 |
title="Image Similarity Checker",
|
35 |
description="Upload two images to compare their similarity based on extracted features using MobileNetV2."
|
36 |
)
|
|
|
23 |
|
24 |
# Compute cosine similarity between features
|
25 |
similarity = np.dot(features1, features2.T)
|
26 |
+
similarity /= (np.linalg.norm(features1) * np.linalg.norm(features2))
|
27 |
return {'Similarity': float(similarity)}
|
28 |
|
29 |
# Setup Gradio interface
|
30 |
iface = gr.Interface(
|
31 |
fn=compare_images,
|
32 |
+
inputs=[gr.components.Image(shape=None), gr.components.Image(shape=None)],
|
33 |
+
outputs=gr.components.Label(),
|
34 |
title="Image Similarity Checker",
|
35 |
description="Upload two images to compare their similarity based on extracted features using MobileNetV2."
|
36 |
)
|