Jamshaid89 commited on
Commit
b58260f
1 Parent(s): 1e1f35f

changed detector backend to retinaface and changed output message of save identity

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -16,14 +16,14 @@ debug=False
16
 
17
  def save_identity(image , name):
18
  try:
19
- embeddings = DeepFace.represent(image , model_name=model_name)
20
  embeddings = embeddings[0]
21
 
22
  identity = {"embeddings":embeddings["embedding"] , "name" : name }
23
 
24
  result = identities_collection.insert_one(identity)
25
 
26
- return str(result)
27
  except Exception as error:
28
  return str(error)
29
 
@@ -69,6 +69,7 @@ def predict_image(image):
69
  target_embedding_array = DeepFace.represent(
70
  img_path=image,
71
  model_name=model_name,
 
72
  )
73
  identities = []
74
  # for each face compare its embeddings with all face embeddings in database
@@ -116,7 +117,7 @@ def predict_image(image):
116
 
117
  # Create Gradio interfaces for input and output
118
  image_input = gr.inputs.Image(shape=(160, 160))
119
- label_input = gr.inputs.Textbox(label="Enter Label")
120
  label_output = gr.outputs.Textbox()
121
 
122
 
@@ -131,7 +132,7 @@ interface1 = gr.Interface(
131
 
132
 
133
  # Create Gradio interfaces for image input and output
134
- image_input2 = gr.inputs.Image(shape=(None, None))
135
  output_image = gr.outputs.Image(type="numpy")
136
  # output_image = gr.outputs.Textbox()
137
 
@@ -155,4 +156,4 @@ gr.TabbedInterface(
155
  ).queue().launch()
156
 
157
  # Launch the Gradio interface
158
- interface.launch()
 
16
 
17
  def save_identity(image , name):
18
  try:
19
+ embeddings = DeepFace.represent(image , model_name=model_name , detector_backend = "retinaface")
20
  embeddings = embeddings[0]
21
 
22
  identity = {"embeddings":embeddings["embedding"] , "name" : name }
23
 
24
  result = identities_collection.insert_one(identity)
25
 
26
+ return f"{name} stored in database successfully.It is recommended to add 2 or 3 high quality images for one person"
27
  except Exception as error:
28
  return str(error)
29
 
 
69
  target_embedding_array = DeepFace.represent(
70
  img_path=image,
71
  model_name=model_name,
72
+ detector_backend = "retinaface"
73
  )
74
  identities = []
75
  # for each face compare its embeddings with all face embeddings in database
 
117
 
118
  # Create Gradio interfaces for input and output
119
  image_input = gr.inputs.Image(shape=(160, 160))
120
+ label_input = gr.inputs.Textbox(label="Enter Name")
121
  label_output = gr.outputs.Textbox()
122
 
123
 
 
132
 
133
 
134
  # Create Gradio interfaces for image input and output
135
+ image_input2 = gr.inputs.Image(shape=(160,160))
136
  output_image = gr.outputs.Image(type="numpy")
137
  # output_image = gr.outputs.Textbox()
138
 
 
156
  ).queue().launch()
157
 
158
  # Launch the Gradio interface
159
+ # interface.launch()