Update app.py
Browse files
app.py
CHANGED
@@ -28,9 +28,17 @@ def image_similarity(target_image, image):
|
|
28 |
target_image = target_image.astype(np.uint8)
|
29 |
image = image.astype(np.uint8)
|
30 |
scores = compute_similarity(target_image, [image])
|
31 |
-
result = (
|
32 |
return [result]
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
# Prepare Gradio interface
|
35 |
iface = gr.Interface(
|
36 |
fn=image_similarity,
|
|
|
28 |
target_image = target_image.astype(np.uint8)
|
29 |
image = image.astype(np.uint8)
|
30 |
scores = compute_similarity(target_image, [image])
|
31 |
+
result = (format_image(image), f"Score: {scores[0]:.4f}")
|
32 |
return [result]
|
33 |
|
34 |
+
# Function to format the image representation as a string
|
35 |
+
def format_image(image):
|
36 |
+
formatted_image = ""
|
37 |
+
for row in image:
|
38 |
+
formatted_row = ", ".join([f"[{', '.join(map(str, pixel))}]" for pixel in row])
|
39 |
+
formatted_image += f"[{formatted_row}], "
|
40 |
+
return formatted_image[:-2]
|
41 |
+
|
42 |
# Prepare Gradio interface
|
43 |
iface = gr.Interface(
|
44 |
fn=image_similarity,
|