Update app.py
Browse files
app.py
CHANGED
@@ -3,18 +3,19 @@ from deepface import DeepFace
|
|
3 |
|
4 |
def face_similarity(img1, img2):
|
5 |
result = DeepFace.verify(img1, img2)
|
6 |
-
|
|
|
7 |
verified = result["verified"]
|
8 |
|
9 |
-
# ์ ์ฌ๋์ ๋ฐ๋ฅธ ๋ฉ์์ง ์กฐ๊ฑด
|
10 |
-
if similarity
|
11 |
message = "๋ ๋ถ์ ์ฒ์์ฐ๋ถ!"
|
12 |
-
elif 0.
|
13 |
message = "๋ ๋ถ์ ๋ด๊บผ์ธ๋ฏ ๋ด๊บผ์๋ ๋ด๊บผ๊ฐ์...?"
|
14 |
else:
|
15 |
message = "์คํ๋ ค ์ข์! ์ ๋ฐ๋์ ์ฌ๋์ด ๋๋ฆด์ง๋ ๋ชฐ๋ผ์"
|
16 |
|
17 |
-
return f"์ ์ฌ๋: {similarity}, ๋งค์นญ ๊ฒฐ๊ณผ: {verified}\n{message}"
|
18 |
|
19 |
iface = gr.Interface(fn=face_similarity,
|
20 |
inputs=[gr.inputs.Image(shape=(224, 224)), gr.inputs.Image(shape=(224, 224))],
|
@@ -24,6 +25,32 @@ iface = gr.Interface(fn=face_similarity,
|
|
24 |
|
25 |
iface.launch()
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
|
29 |
# import gradio as gr
|
|
|
3 |
|
4 |
def face_similarity(img1, img2):
|
5 |
result = DeepFace.verify(img1, img2)
|
6 |
+
# distance ๊ฐ์ 1์์ ๋นผ์ similarity๋ก ์ฌ์ฉ
|
7 |
+
similarity = 1 - result["distance"] # ์ด์ ๋์์๋ก ๋ ์ ์ฌ
|
8 |
verified = result["verified"]
|
9 |
|
10 |
+
# ์ ์ฌ๋์ ๋ฐ๋ฅธ ๋ฉ์์ง ์กฐ๊ฑด ๋ถ๊ธฐ, ์ด์ similarity ๊ฐ์ด ๋์์๋ก ์ ์ฌํ ๊ฒ์ผ๋ก ์ฒ๋ฆฌ
|
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}, ๋งค์นญ ๊ฒฐ๊ณผ: {verified}\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 |
+
# import gradio as gr
|
29 |
+
# from deepface import DeepFace
|
30 |
+
|
31 |
+
# def face_similarity(img1, img2):
|
32 |
+
# result = DeepFace.verify(img1, img2)
|
33 |
+
# similarity = result["distance"] # ๋ฎ์์๋ก ๋ ์ ์ฌ
|
34 |
+
# verified = result["verified"]
|
35 |
+
|
36 |
+
# # ์ ์ฌ๋์ ๋ฐ๋ฅธ ๋ฉ์์ง ์กฐ๊ฑด ๋ถ๊ธฐ
|
37 |
+
# if similarity >= 0.5:
|
38 |
+
# message = "๋ ๋ถ์ ์ฒ์์ฐ๋ถ!"
|
39 |
+
# elif 0.3 <= similarity < 0.5:
|
40 |
+
# message = "๋ ๋ถ์ ๋ด๊บผ์ธ๋ฏ ๋ด๊บผ์๋ ๋ด๊บผ๊ฐ์...?"
|
41 |
+
# else:
|
42 |
+
# message = "์คํ๋ ค ์ข์! ์ ๋ฐ๋์ ์ฌ๋์ด ๋๋ฆด์ง๋ ๋ชฐ๋ผ์"
|
43 |
+
|
44 |
+
# return f"์ ์ฌ๋: {similarity}, ๋งค์นญ ๊ฒฐ๊ณผ: {verified}\n{message}"
|
45 |
+
|
46 |
+
# iface = gr.Interface(fn=face_similarity,
|
47 |
+
# inputs=[gr.inputs.Image(shape=(224, 224)), gr.inputs.Image(shape=(224, 224))],
|
48 |
+
# outputs="text",
|
49 |
+
# title="์ผ๊ตด ์ ์ฌ๋ ์ธก์ ",
|
50 |
+
# description="๋ ์ผ๊ตด ์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํด์ ์ ์ฌ๋๋ฅผ ์ธก์ ํฉ๋๋ค.")
|
51 |
+
|
52 |
+
# iface.launch()
|
53 |
+
|
54 |
|
55 |
|
56 |
# import gradio as gr
|