18 |
19 | deepface-react-ui is a comprehensive user interface for facial recognition and facial attribute analysis (age, gender, emotion and race prediction) built with ReactJS, designed specifically for streamlined face verification tasks using the [DeepFace](https://github.com/serengil/deepface) library. This UI not only simplifies the implementation of facial recognition features but also enhances security with built-in [anti-spoofing](https://youtu.be/UiK1aIjOBlQ) capabilities. Whether you're working on identity verification systems, security applications, or simply exploring facial recognition technology, this UI provides an intuitive platform to harness the power of DeepFace within your web applications.
20 |
21 | Facial recognition technology plays a pivotal role in modern applications, from enhancing security measures to enabling personalized user experiences. The deepface-react-ui empowers developers and researchers to harness these capabilities effortlessly within their web applications.
22 |
23 |
24 |
25 | ## Cloning The Service
26 |
27 | Firstly, you should clone both deepface and deepface-react-ui repos in same directory.
28 |
29 | ```shell
30 | # clone deepface repo
31 | git clone https://github.com/serengil/deepface-react-ui.git \
32 | && git clone https://github.com/serengil/deepface.git
33 | ```
34 |
35 | ## Facial Database Configuration
36 |
37 | There is `.env.example` file in the root of the project. You should copy this as `.env`. Required modifications are mentioned as comments. You basically need to add your facial database items into this file, prefixing each with `REACT_APP_USER_`, where the identity name with that prefix serves as the key and the base64-encoded string of their images serves as the value.
38 |
39 | ```yaml
40 | # define your facial database
41 | REACT_APP_USER_ALICE=data:image/png;base64,...
42 | REACT_APP_USER_BOB=data:image/png;base64,...
43 | REACT_APP_USER_CAROL=data:image/png;base64,...
44 | ```
45 |
46 | ## Model Configuration (Optional)
47 |
48 | DeepFace wraps many state-of-the-art facial recognition models: [`VGG-Face`](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/), [`FaceNet`](https://sefiks.com/2018/09/03/face-recognition-with-facenet-in-keras/), [`OpenFace`](https://sefiks.com/2019/07/21/face-recognition-with-openface-in-keras/), [`DeepFace`](https://sefiks.com/2020/02/17/face-recognition-with-facebook-deepface-in-keras/), [`DeepID`](https://sefiks.com/2020/06/16/face-recognition-with-deepid-in-keras/), [`ArcFace`](https://sefiks.com/2020/12/14/deep-face-recognition-with-arcface-in-keras-and-python/), [`Dlib`](https://sefiks.com/2020/07/11/face-recognition-with-dlib-in-python/), `SFace` and `GhostFaceNet`. According to [`experiments`](https://github.com/serengil/deepface/tree/master/benchmarks), those models reached or passed human-level accuracy.
49 |
50 | Similarly, it wraps many cutting-edge face detectors: [`OpenCV`](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [`Ssd`](https://sefiks.com/2020/08/25/deep-face-detection-with-opencv-in-python/), [`Dlib`](https://sefiks.com/2020/07/11/face-recognition-with-dlib-in-python/), [`MtCnn`](https://sefiks.com/2020/09/09/deep-face-detection-with-mtcnn-in-python/), `Faster MtCnn`, [`RetinaFace`](https://sefiks.com/2021/04/27/deep-face-detection-with-retinaface-in-python/), [`MediaPipe`](https://sefiks.com/2022/01/14/deep-face-detection-with-mediapipe/), `Yolo`, `YuNet` and `CenterFace`.
51 |
52 | Both facial recognition models and face detectors can be set in the `.env` file.
53 |
54 | ```yaml
55 | # Set facial recognition model: VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepId, ArcFace, Dlib, SFace, GhostFaceNet
56 | REACT_APP_FACE_RECOGNITION_MODEL=Facenet
57 |
58 | # Set face detector: opencv, ssd, mtcnn, dlib, mediapipe, retinaface, yolov8, yunet, centerface
59 | REACT_APP_DETECTOR_BACKEND=opencv
60 |
61 | # Set distance metric: cosine, euclidean, euclidean_l2
62 | REACT_APP_DISTANCE_METRIC=cosine
63 | ```
64 |
65 | ## Running Service Directly
66 |
67 | Firstly, you should run the deepface service as
68 |
69 | ```shell
70 | # go to project's directory
71 | cd deepface/scripts
72 |
73 | # run the dockerized service
74 | ./dockerize.sh
75 |
76 | # or instead of running dockerized service, run it directly if you installed requirements.txt
77 | # ./service.sh
78 | ```
79 |
80 | In seperate terminal, you should run deepface react ui as
81 |
82 | ```shell
83 | # go to project's directory
84 | cd deepface-react-ui/scripts
85 |
86 | # run the dockerized service
87 | ./dockerize.sh
88 |
89 | # or instead of running dockerized service, run it directly
90 | # ./service.sh
91 | ```
92 |
93 | ## Running via Docker Compose
94 |
95 | Instead of running deepface and deepface react ui seperately in different terminals, you can run the standalone docker compose.
96 |
97 | ```shell
98 | # clone source code
99 | git clone https://github.com/serengil/deepface-react-ui.git \
100 | && git clone https://github.com/serengil/deepface.git
101 |
102 | # go to project's directory
103 | cd deepface-react-ui/scripts
104 |
105 | # run services
106 | ./compose.sh
107 | ```
108 |
109 | ## Using The App - [`Demo`](https://youtu.be/IXoah6rhxac)
110 |
111 | Once you start the service, the DeepFace service will be accessible at `http://localhost:5005/`, and the DeepFace React UI will be available at `http://localhost:3000/`.
112 |
113 | To use the DeepFace React UI, open `http://localhost:3000/` in your browser. The UI will prompt access to your webcam and search for identities within the current frame using the facial database specified in the `.env` file when you click on the "Verify" button.
114 |
115 | ## Facial Attribute Analysis - [`Demo`](https://youtu.be/_waBA-cH2D4)
116 |
117 | UI also supports demography analysis including age, gender, emotion and race & ethnicity prediction tasks.
118 |
119 |
120 |
121 | ## Support
122 |
123 | There are many ways to support a project - starring⭐️ the GitHub repo is just one 🙏
124 |
125 | If you do like this work, then you can support it on [Patreon](https://www.patreon.com/serengil?repo=deepface), [GitHub Sponsors](https://github.com/sponsors/serengil) or [Buy Me a Coffee](https://buymeacoffee.com/serengil).
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | # Citation
136 |
137 | Please cite deepface-react-ui in your publications if it helps your research. Here is its BibTex entry:
138 |
139 | ```BibTeX
140 | @article{serengil2024lightface,
141 | title = {A Benchmark of Facial Recognition Pipelines and Co-Usability Performances of Modules},
142 | author = {Serengil, Sefik and Ozpinar, Alper},
143 | journal = {Journal of Information Technologies},
144 | volume = {17},
145 | number = {2},
146 | pages = {95-107},
147 | year = {2024},
148 | doi = {10.17671/gazibtd.1399077},
149 | url = {https://dergipark.org.tr/en/pub/gazibtd/issue/84331/1399077},
150 | publisher = {Gazi University}
151 | }
152 | ```
153 |
154 | ## Licence
155 |
156 | DeepFace React UI is licensed under the MIT License - see [`LICENSE`](https://github.com/serengil/deepface-react-ui/blob/main/LICENSE) for more details.
157 |
--------------------------------------------------------------------------------