Spaces:
Runtime error
Runtime error
Hiroaki Ogasawara commited on
Commit ·
4557257
1
Parent(s): 79f7841
chore: add hashes
Browse files
app.py
CHANGED
|
@@ -18,10 +18,22 @@ def compare_images(img1, img2):
|
|
| 18 |
d_hash2 = imagehash.dhash(img2)
|
| 19 |
hashes["dhash"] = d_hash1 - d_hash2
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
w_hash1 = imagehash.whash(img1)
|
| 22 |
w_hash2 = imagehash.whash(img2)
|
| 23 |
hashes["whash"] = w_hash1 - w_hash2
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
return hashes
|
| 26 |
|
| 27 |
|
|
@@ -31,7 +43,7 @@ with gr.Blocks() as iface:
|
|
| 31 |
with gr.Row():
|
| 32 |
img1 = gr.Image(type="pil")
|
| 33 |
img2 = gr.Image(type="pil")
|
| 34 |
-
output = gr.
|
| 35 |
btn = gr.Button("計算")
|
| 36 |
btn.click(compare_images, inputs=[img1, img2], outputs=output)
|
| 37 |
|
|
|
|
| 18 |
d_hash2 = imagehash.dhash(img2)
|
| 19 |
hashes["dhash"] = d_hash1 - d_hash2
|
| 20 |
|
| 21 |
+
d_hash_v1 = imagehash.dhash_vertical(img1)
|
| 22 |
+
d_hash_v2 = imagehash.dhash_vertical(img2)
|
| 23 |
+
hashes["dhash_vertical"] = d_hash_v1 - d_hash_v2
|
| 24 |
+
|
| 25 |
w_hash1 = imagehash.whash(img1)
|
| 26 |
w_hash2 = imagehash.whash(img2)
|
| 27 |
hashes["whash"] = w_hash1 - w_hash2
|
| 28 |
|
| 29 |
+
color_hash1 = imagehash.colorhash(img1)
|
| 30 |
+
color_hash2 = imagehash.colorhash(img2)
|
| 31 |
+
hashes["colorhash"] = color_hash1 - color_hash2
|
| 32 |
+
|
| 33 |
+
crop_resistant_hash1 = imagehash.crop_resistant_hash(img1)
|
| 34 |
+
crop_resistant_hash2 = imagehash.crop_resistant_hash(img2)
|
| 35 |
+
hashes["crop_resistant_hash"] = crop_resistant_hash1 - crop_resistant_hash2
|
| 36 |
+
|
| 37 |
return hashes
|
| 38 |
|
| 39 |
|
|
|
|
| 43 |
with gr.Row():
|
| 44 |
img1 = gr.Image(type="pil")
|
| 45 |
img2 = gr.Image(type="pil")
|
| 46 |
+
output = gr.JSON()
|
| 47 |
btn = gr.Button("計算")
|
| 48 |
btn.click(compare_images, inputs=[img1, img2], outputs=output)
|
| 49 |
|