suinY00N commited on
Commit
d68691f
โ€ข
1 Parent(s): a75a347

Update app.py

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