├── .dockerignore
├── .env.example
├── .github
└── FUNDING.yml
├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── docker-compose.yml
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
├── resources
├── demography.jpg
└── tp.jpg
├── scripts
├── compose.sh
├── dockerize.sh
└── service.sh
└── src
├── App.css
├── App.js
├── App.test.js
├── index.css
├── index.js
├── logo.svg
├── reportWebVitals.js
└── setupTests.js
/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | build
3 | npm-debug.log
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | # backend deepface service's endpoint, do not change if not necessary
2 | REACT_APP_SERVICE_ENDPOINT=http://localhost:5005
3 |
4 | # Set facial recognition model: VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepId, ArcFace, Dlib, SFace, GhostFaceNet
5 | REACT_APP_FACE_RECOGNITION_MODEL=Facenet
6 |
7 | # Set face detector: opencv, ssd, mtcnn, dlib, mediapipe, retinaface, yolov8, yunet, centerface
8 | REACT_APP_DETECTOR_BACKEND=opencv
9 |
10 | # Set distance metric: cosine, euclidean, euclidean_l2
11 | REACT_APP_DISTANCE_METRIC=cosine
12 |
13 | # Set REACT_APP_ANTI_SPOOFING to 1 if you want to enable anti-spoofing
14 | REACT_APP_ANTI_SPOOFING=0
15 |
16 | # define your facial database
17 | REACT_APP_USER_YOUR_NAME=data:image/png;base64,...
18 | REACT_APP_USER_YOUR_FRIENDS_NAME=data:image/png;base64,...
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: serengil
2 | patreon: serengil
3 | buy_me_a_coffee: serengil
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env
17 | .env.local
18 | .env.development.local
19 | .env.test.local
20 | .env.production.local
21 |
22 | npm-debug.log*
23 | yarn-debug.log*
24 | yarn-error.log*
25 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # Use an official Node.js runtime as a parent image
2 | FROM node:14-alpine
3 |
4 | # Set the working directory in the container
5 | WORKDIR /app
6 |
7 | # Copy package.json and package-lock.json to the working directory
8 | COPY package*.json ./
9 |
10 | # Install dependencies
11 | RUN npm install
12 |
13 | # Copy the rest of the application code to the working directory
14 | COPY . .
15 |
16 | # Expose port 3000 to the outside world
17 | EXPOSE 3000
18 |
19 | # Start the React application
20 | CMD ["npm", "start"]
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Sefik Ilkin Serengil
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DeepFace React UI
2 |
3 |
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 |