RajaThor commited on
Commit
e9bf10d
·
verified ·
1 Parent(s): bd2f5df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -177,11 +177,14 @@ def recognize_face_optimal(image_path):
177
  if matches:
178
  best_match = min(matches, key=lambda x: x[1])
179
  best_name, best_score = best_match
180
- info = ref.child(best_name).child("info").get()
181
- insta_handle = info["instagram_handle"]
182
- insta_link = info["instagram_link"]
183
- insta_link_html = f'<a href="{insta_link}" target="_blank"><font color="red">{insta_handle}</font></a>'
184
- return f"Best match: {best_name} with a similarity score of {1 - best_score:.2%}. Insta handle: {insta_link_html}"
 
 
 
185
  else:
186
  return "Face not found in the database."
187
  except Exception as e:
 
177
  if matches:
178
  best_match = min(matches, key=lambda x: x[1])
179
  best_name, best_score = best_match
180
+ if best_score >= 0.48: # Adjust the threshold as needed
181
+ info = ref.child(best_name).child("info").get()
182
+ insta_handle = info["instagram_handle"]
183
+ insta_link = info["instagram_link"]
184
+ insta_link_html = f'<a href="{insta_link}" target="_blank"><font color="red">{insta_handle}</font></a>'
185
+ return f"Best match: {best_name} with a similarity score of {1 - best_score:.2%}. Insta handle: {insta_link_html}"
186
+ else:
187
+ return "Face not found."
188
  else:
189
  return "Face not found in the database."
190
  except Exception as e: