| import gradio as gr | |
| import cv2 | |
| import numpy as np | |
| import face_recognition | |
| def recognize_faces(image): | |
| np_img = np.array(image) | |
| face_locations = face_recognition.face_locations(np_img) | |
| response = f"Faces detected: {len(face_locations)}\nLocations: {face_locations}" | |
| return response | |
| iface = gr.Interface( | |
| fn=recognize_faces, | |
| inputs=gr.Image(type="numpy"), | |
| outputs="text", | |
| title="Face Recognition App", | |
| description="Upload an image to detect faces." | |
| ) | |
| iface.launch() |