Hiroaki Ogasawara
refactor: packages
59d0eb8
raw
history blame
670 Bytes
import gradio as gr
import imagehash
def compare_images(img1, img2):
if img1 is None or img2 is None:
return "画像を2つともアップロードしてください。"
hash1 = imagehash.average_hash(img1)
hash2 = imagehash.average_hash(img2)
diff = hash1 - hash2
return f"2つの画像のハッシュ差異は: {diff} です。"
iface = gr.Interface(
fn=compare_images,
inputs=[gr.Image(type="pil"), gr.Image(type="pil")],
outputs="text",
title="画像ハッシュ差分計算アプリ",
description="2つの画像をアップロードして、imagehashでハッシュの差を計算します。",
)
iface.launch()