Spaces:
Runtime error
Runtime error
Commit
Β·
31d68e1
1
Parent(s):
59a4fbe
initial commit
Browse files- __pycache__/app.cpython-310.pyc +0 -0
- app.py +51 -0
- requirements.txt +9 -0
__pycache__/app.cpython-310.pyc
ADDED
|
Binary file (2.32 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import face_recognition
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def run_verification(verification_image, input_image):
|
| 6 |
+
temp = face_recognition.face_encodings(verification_image)
|
| 7 |
+
if len(temp) == 1:
|
| 8 |
+
verification_encoding = face_recognition.face_encodings(verification_image)[0]
|
| 9 |
+
elif len(temp)>1:
|
| 10 |
+
return 'Multiple faces detected in verification image β. Verification Image must have a single face'
|
| 11 |
+
else:
|
| 12 |
+
return 'No face detected in verification image β. Verification Image must have a single face'
|
| 13 |
+
|
| 14 |
+
temp = face_recognition.face_encodings(input_image)
|
| 15 |
+
if len(temp) == 1:
|
| 16 |
+
input_encoding = face_recognition.face_encodings(input_image)[0]
|
| 17 |
+
elif len(temp)>1:
|
| 18 |
+
input_encoding = face_recognition.face_encodings(input_image)[0]
|
| 19 |
+
multiple_people=True
|
| 20 |
+
else:
|
| 21 |
+
return 'No face detected in Input Image.'
|
| 22 |
+
|
| 23 |
+
results = face_recognition.compare_faces([verification_encoding], input_encoding)
|
| 24 |
+
|
| 25 |
+
if results[0]==True and not multiple_people:
|
| 26 |
+
return 'Facial Verification Successful β
. Both pictures contain the same person'
|
| 27 |
+
elif results[0]==True and multiple_people:
|
| 28 |
+
return 'Facial Verification Successful β
. Both pictures contain the same person. Input Image contains multiple faces.'
|
| 29 |
+
else:
|
| 30 |
+
return 'Facial Verification Failed β. Both pictures contain different persons'
|
| 31 |
+
|
| 32 |
+
with gr.Blocks() as demo:
|
| 33 |
+
gr.Markdown("# FaceMatch: A Zero Shot Facial Recognition App")
|
| 34 |
+
gr.Markdown("FaceMatch is a cutting-edge facial recognition application that allows users to compare two images to determine if they depict the same person or not. Unlike traditional facial recognition systems that require a database of known faces, FaceMatch utilizes zero-shot facial recognition technology, which means it can recognize individuals without any prior training using just a single anchor image.")
|
| 35 |
+
gr.Markdown('''
|
| 36 |
+
Steps to Run:
|
| 37 |
+
1. Upload your verified image as a reference.
|
| 38 |
+
2. Upload the image to be verified for comparison.
|
| 39 |
+
3. Click "Run Facial Recognition" to initiate the process.
|
| 40 |
+
4. View the verification result.
|
| 41 |
+
''')
|
| 42 |
+
gr.Info('Test')
|
| 43 |
+
with gr.Row():
|
| 44 |
+
verification_image = gr.Image(label='Verification Image')
|
| 45 |
+
input_image = gr.Image(label = 'Input Image')
|
| 46 |
+
verify_button = gr.Button(value="Run Facial Recognition")
|
| 47 |
+
output_textbox = gr.Textbox(value="", label="Verification Result")
|
| 48 |
+
verify_button.click(run_verification, inputs=[verification_image, input_image], outputs=[output_textbox])
|
| 49 |
+
# upload_button.upload(upload_file, upload_button, file_output)
|
| 50 |
+
|
| 51 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
opencv-python
|
| 3 |
+
face-recognition
|
| 4 |
+
face_recognition_models
|
| 5 |
+
Click>=6.0
|
| 6 |
+
dlib>=19.3.0
|
| 7 |
+
numpy
|
| 8 |
+
Pillow
|
| 9 |
+
scipy>=0.17.0
|