Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,21 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from deepface import DeepFace
|
3 |
|
4 |
def face_similarity(img1, img2):
|
5 |
result = DeepFace.verify(img1, img2)
|
6 |
-
# distance
|
7 |
-
similarity = 1 - result["distance"]
|
8 |
-
verified = result["verified"]
|
9 |
|
10 |
-
# ์ ์ฌ๋์ ๋ฐ๋ฅธ ๋ฉ์์ง ์กฐ๊ฑด
|
11 |
-
if similarity > 0.
|
12 |
message = "๋ ๋ถ์ ์ฒ์์ฐ๋ถ!"
|
13 |
-
elif 0.4 < similarity <= 0.
|
14 |
message = "๋ ๋ถ์ ๋ด๊บผ์ธ๋ฏ ๋ด๊บผ์๋ ๋ด๊บผ๊ฐ์...?"
|
15 |
else:
|
16 |
message = "์คํ๋ ค ์ข์! ์ ๋ฐ๋์ ์ฌ๋์ด ๋๋ฆด์ง๋ ๋ชฐ๋ผ์"
|
17 |
|
18 |
-
return f"์ ์ฌ๋: {similarity:.2f}
|
19 |
|
20 |
iface = gr.Interface(fn=face_similarity,
|
21 |
inputs=[gr.inputs.Image(shape=(224, 224)), gr.inputs.Image(shape=(224, 224))],
|
@@ -25,6 +25,7 @@ iface = gr.Interface(fn=face_similarity,
|
|
25 |
|
26 |
iface.launch()
|
27 |
|
|
|
28 |
# import gradio as gr
|
29 |
# from deepface import DeepFace
|
30 |
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
from deepface import DeepFace
|
4 |
|
5 |
def face_similarity(img1, img2):
|
6 |
result = DeepFace.verify(img1, img2)
|
7 |
+
# distance๋ฅผ ์ด์ฉํด ์ ์ฌ๋๋ฅผ 1์์ ๋นผ์ ๋์์๋ก ์ ์ฌํ๊ฒ ๋ณํ
|
8 |
+
similarity = 1 - result["distance"]
|
|
|
9 |
|
10 |
+
# ์ ์ฌ๋์ ๋ฐ๋ฅธ ๋ฉ์์ง ์กฐ๊ฑด ๋ถ๊ธฐ
|
11 |
+
if similarity > 0.7:
|
12 |
message = "๋ ๋ถ์ ์ฒ์์ฐ๋ถ!"
|
13 |
+
elif 0.4 < similarity <= 0.7:
|
14 |
message = "๋ ๋ถ์ ๋ด๊บผ์ธ๋ฏ ๋ด๊บผ์๋ ๋ด๊บผ๊ฐ์...?"
|
15 |
else:
|
16 |
message = "์คํ๋ ค ์ข์! ์ ๋ฐ๋์ ์ฌ๋์ด ๋๋ฆด์ง๋ ๋ชฐ๋ผ์"
|
17 |
|
18 |
+
return f"์ ์ฌ๋: {similarity:.2f}\n{message}"
|
19 |
|
20 |
iface = gr.Interface(fn=face_similarity,
|
21 |
inputs=[gr.inputs.Image(shape=(224, 224)), gr.inputs.Image(shape=(224, 224))],
|
|
|
25 |
|
26 |
iface.launch()
|
27 |
|
28 |
+
|
29 |
# import gradio as gr
|
30 |
# from deepface import DeepFace
|
31 |
|