Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,25 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import face_recognition
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
|
6 |
+
def match_faces(image1, image2):
|
7 |
+
# ์ด๋ฏธ์ง์์ ์ผ๊ตด ์ธ์ ๋ฐ ํน์ง ์ถ์ถ
|
8 |
+
face_encoding1 = face_recognition.face_encodings(image1)[0]
|
9 |
+
face_encoding2 = face_recognition.face_encodings(image2)[0]
|
10 |
+
|
11 |
+
# ๋ ์ผ๊ตด ๊ฐ์ ์ ์ฌ๋ ์ธก์ (์ ํด๋ฆฌ๋์ ๊ฑฐ๋ฆฌ)
|
12 |
+
distance = np.linalg.norm(face_encoding1 - face_encoding2)
|
13 |
+
|
14 |
+
# ์ ์ฌ๋์ ๋ฐ๋ผ ๊ฒฐ๊ณผ ๋ฐํ
|
15 |
+
if distance < 0.6:
|
16 |
+
return "์ผ๊ตด์ด ๋งค์ฐ ๋น์ทํฉ๋๋ค!"
|
17 |
+
else:
|
18 |
+
return "์ผ๊ตด์ด ๋ค๋ฆ
๋๋ค."
|
19 |
+
|
20 |
+
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
21 |
+
iface = gr.Interface(fn=match_faces,
|
22 |
+
inputs=[gr.inputs.Image(shape=(224, 224)), gr.inputs.Image(shape=(224, 224))],
|
23 |
+
outputs="text")
|
24 |
|
25 |
+
iface.launch()
|