This project demonstrates how to create a real-time face detection application using MediaPipe and Streamlit. The application captures video from the webcam, detects faces, and displays the results in real-time.
You can try the live demo of the application at: https://tiennhm-face-detection-realtime.streamlit.app/
- Real-time face detection using webcam input.
- Upload an image for face detection.
- Upload a video file for face detection.
- Display detected faces with bounding boxes.
- User-friendly interface with Streamlit.
- Python 3.7 or higher
- Streamlit
- MediaPipe
- OpenCV
-
Clone the repository:
git clone https://github.com/TienNHM/face-detection-realtime.git
-
Create a virtual environment (optional but recommended):
- On Windows:
python -m venv venv venv\Scripts\activate
- On macOS/Linux:
python3 -m venv venv source venv/bin/activate -
Install the required packages:
pip install -r requirements.txt
To run the application, execute the following command in your terminal:
streamlit run app.pyThis will start a local server and open the application in your default web browser. Visit http://localhost:8501 to view the application.
To run the application using Docker, follow these steps:
-
Build the Docker image:
docker build -t face-detection-app . -
Run the Docker container:
docker run -p 8501:8501 face-detection-app docker run -it --rm --device=/dev/video0 --privileged -p 8501:8501 face-detection-app
This will start the application in a Docker container, and you can access it at http://localhost:8501.
sudo on Linux systems. If you are running on Windows using Docker Desktop, you CANNOT access the webcam directly. Instead, you can use the image/video upload feature only.
If you would like to contribute to this project, feel free to submit a pull request or open an issue for any bugs or feature requests.

