Update app.py
Browse files
app.py
CHANGED
|
@@ -172,19 +172,18 @@ def recognize_face_optimal(image_path):
|
|
| 172 |
for name, data in ref.get().items():
|
| 173 |
known_encoding = np.array(data["encoding"])
|
| 174 |
similarity_score = face_recognition.face_distance([known_encoding], unknown_encoding[0])[0]
|
|
|
|
|
|
|
| 175 |
matches.append((name, similarity_score))
|
| 176 |
|
| 177 |
if matches:
|
| 178 |
best_match = min(matches, key=lambda x: x[1])
|
| 179 |
best_name, best_score = best_match
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 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:
|
|
|
|
| 172 |
for name, data in ref.get().items():
|
| 173 |
known_encoding = np.array(data["encoding"])
|
| 174 |
similarity_score = face_recognition.face_distance([known_encoding], unknown_encoding[0])[0]
|
| 175 |
+
if similarity_score < 0.50: # Adjust the threshold as needed
|
| 176 |
+
continue # Skip this match if similarity score is below 50.00%
|
| 177 |
matches.append((name, similarity_score))
|
| 178 |
|
| 179 |
if matches:
|
| 180 |
best_match = min(matches, key=lambda x: x[1])
|
| 181 |
best_name, best_score = best_match
|
| 182 |
+
info = ref.child(best_name).child("info").get()
|
| 183 |
+
insta_handle = info["instagram_handle"]
|
| 184 |
+
insta_link = info["instagram_link"]
|
| 185 |
+
insta_link_html = f'<a href="{insta_link}" target="_blank"><font color="red">{insta_handle}</font></a>'
|
| 186 |
+
return f"Best match: {best_name} with a similarity score of {1 - best_score:.2%}. Insta handle: {insta_link_html}"
|
|
|
|
|
|
|
|
|
|
| 187 |
else:
|
| 188 |
return "Face not found in the database."
|
| 189 |
except Exception as e:
|