retir commited on
Commit
88ea329
·
1 Parent(s): 73af5b7
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -70,15 +70,21 @@ def edit_bar(photo):
70
  sleep(wait_time)
71
  photo.save("image.png")
72
  if current_perc > 30 and not check_id:
73
- # if photo.size != (1920, 1080):
74
- # error_text = '''<div style="border: 3px solid red;"><div style="font-size:3em;text-align:center; color:red">Ошибка!</div>
75
- # <div style="text-align:center; font-size:2em">Судя по всему вы используете неправильную вебкамеру! Попытайтесь снова.</div></div>'''
76
- # yield gr.update(visible=False), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True, value=error_text)gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
77
- # return
78
- embedding_objs = DeepFace.represent(
79
- img_path = "image.png",
80
- model_name = "Facenet512",
81
- )
 
 
 
 
 
 
82
  embed = torch.Tensor(embedding_objs[0]['embedding'])
83
  alex_embed = torch.load("Alex_embed.pt")
84
  print(embed.shape, alex_embed.shape)
 
70
  sleep(wait_time)
71
  photo.save("image.png")
72
  if current_perc > 30 and not check_id:
73
+ if photo.size != (1920, 1080):
74
+ error_text = '''<div style="border: 3px solid red;"><div style="font-size:3em;text-align:center; color:red">Ошибка!</div>
75
+ <div style="text-align:center; font-size:2em">Судя по всему вы используете неправильную вебкамеру! Попытайтесь снова.</div></div>'''
76
+ yield gr.update(visible=False), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True, value=error_text), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
77
+ return
78
+ try:
79
+ embedding_objs = DeepFace.represent(
80
+ img_path = "image.png",
81
+ model_name = "Facenet512",
82
+ )
83
+ except ValueError:
84
+ error_text = '''<div style="border: 3px solid red;"><div style="font-size:3em;text-align:center; color:red">Ошибка!</div>
85
+ <div style="text-align:center; font-size:2em">Не можем найти лицо на фото! Попытайтесь сделать снимок снова.</div></div>'''
86
+ yield gr.update(visible=False), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True, value=error_text), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
87
+ return
88
  embed = torch.Tensor(embedding_objs[0]['embedding'])
89
  alex_embed = torch.load("Alex_embed.pt")
90
  print(embed.shape, alex_embed.shape)