|
import gradio as gr |
|
import face_recognition |
|
import numpy as np |
|
from PIL import Image |
|
|
|
def match_faces(image1, image2): |
|
|
|
face_encoding1 = face_recognition.face_encodings(image1)[0] |
|
face_encoding2 = face_recognition.face_encodings(image2)[0] |
|
|
|
|
|
distance = np.linalg.norm(face_encoding1 - face_encoding2) |
|
|
|
|
|
|
|
|
|
similarity = max(0, 100 - (distance / 0.6) * 100) |
|
|
|
return f"๋ ์ผ๊ตด์ ์ ์ฌ๋๋ {similarity:.2f}% ์
๋๋ค." |
|
|
|
return f"์ ์ฌ๋: {similarity:.2f}%" |
|
|
|
|
|
iface = gr.Interface(fn=match_faces, |
|
inputs=[gr.inputs.Image(shape=(224, 224)), gr.inputs.Image(shape=(224, 224))], |
|
outputs="text") |
|
|
|
iface.launch() |
|
|
|
|