|
import gradio as gr |
|
from deepface import DeepFace |
|
import pandas as pd |
|
import os |
|
|
|
|
|
results = [] |
|
|
|
def save_results(img1_path, img2_path, similarity): |
|
|
|
results.append([img1_path, img2_path, similarity]) |
|
|
|
df = pd.DataFrame(results, columns=['Image 1', 'Image 2', 'Similarity']) |
|
|
|
df.to_csv('similarity_results.csv', index=False) |
|
|
|
def face_similarity(img1, img2): |
|
result = DeepFace.verify(img1, img2) |
|
similarity = result["distance"] |
|
verified = result["verified"] |
|
|
|
|
|
img1_path = f"img1_{len(results)}.jpg" |
|
img2_path = f"img2_{len(results)}.jpg" |
|
img1.save(img1_path) |
|
img2.save(img2_path) |
|
|
|
|
|
save_results(img1_path, img2_path, similarity) |
|
|
|
return f"유사도: {similarity}, 인증 결과: {verified}" |
|
|
|
iface = gr.Interface(fn=face_similarity, |
|
inputs=[gr.inputs.Image(shape=(224, 224)), gr.inputs.Image(shape=(224, 224))], |
|
outputs="text", |
|
title="얼굴 유사도 측정", |
|
description="두 얼굴 이미지를 업로드해서 유사도를 측정합니다.") |
|
|
|
iface.launch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|