suinY00N commited on
Commit
beacc91
โ€ข
1 Parent(s): 629f3d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -1,4 +1,25 @@
1
- import os
 
 
 
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- exec(os.environ.get('CODE'))
 
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()