suinY00N commited on
Commit
85b6cb5
โ€ข
1 Parent(s): 23df74f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -5
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
- similarity = result["distance"] # ๋‚ฎ์„์ˆ˜๋ก ๋” ์œ ์‚ฌ
 
7
  verified = result["verified"]
8
 
9
- # ์œ ์‚ฌ๋„์— ๋”ฐ๋ฅธ ๋ฉ”์‹œ์ง€ ์กฐ๊ฑด ๋ถ„๊ธฐ
10
- if similarity >= 0.5:
11
  message = "๋‘ ๋ถ„์€ ์ฒœ์ƒ์—ฐ๋ถ„!"
12
- elif 0.3 <= similarity < 0.5:
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