{"id":24576113,"url":"https://github.com/spring-0/face-censor","last_synced_at":"2025-03-17T12:41:40.737Z","repository":{"id":272661827,"uuid":"917358577","full_name":"Spring-0/face-censor","owner":"Spring-0","description":"Detect and blur faces in any input images or videos with AI.","archived":false,"fork":false,"pushed_at":"2025-02-02T04:32:58.000Z","size":33075,"stargazers_count":27,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T05:22:08.351Z","etag":null,"topics":["blur-faces","blur-image","computer-vision","face-blur","face-detection","image-processing","machine-learning","opencv","privacy","python","video-processing","yolo","yolov8"],"latest_commit_sha":null,"homepage":"https://huggingface.co/spaces/Spring-0/face-censor","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Spring-0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-15T20:42:28.000Z","updated_at":"2025-02-02T04:33:02.000Z","dependencies_parsed_at":"2025-01-15T22:55:15.413Z","dependency_job_id":"baa6f0a7-bb3b-4360-a8ba-257d2d584f33","html_url":"https://github.com/Spring-0/face-censor","commit_stats":null,"previous_names":["spring-0/face-censor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spring-0%2Fface-censor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spring-0%2Fface-censor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spring-0%2Fface-censor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spring-0%2Fface-censor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Spring-0","download_url":"https://codeload.github.com/Spring-0/face-censor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244036163,"owners_count":20387466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blur-faces","blur-image","computer-vision","face-blur","face-detection","image-processing","machine-learning","opencv","privacy","python","video-processing","yolo","yolov8"],"created_at":"2025-01-23T22:21:29.240Z","updated_at":"2025-03-17T12:41:40.731Z","avatar_url":"https://github.com/Spring-0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Sync with HF Status](https://github.com/Spring-0/face-censor/actions/workflows/sync_to_hub.yml/badge.svg?branch=main)\n\n# Face Detection and Censoring System\n\nA Python-based system for detecting faces in images and videos using YOLOv8, with the ability to censor detected faces. The system is designed to be modular and extensible.\n\n## Features\n\n- Face detection using YOLOv8\n- Support for both image and video processing\n- Easy to use User Interface\n- Modular censoring system\n- Trained on the WIDER FACE dataset via Roboflow\n- Multiple masking methods including: blur, emoji, and text (see [demo](#demo))\n\n## Local Installation\n\n### With Docker 🐋\n1. Pull the image:\n```bash\ndocker pull spring93/face-censor\n```\n\n2. Run:\n```bash\ndocker run -p 3000:7860 -it --gpus all spring93/face-censor\n```\n\n3. Navigate to `http://localhost:3000` from your browser.\n\n### Without Docker\n1. Clone the repository:\n```bash\ngit clone https://github.com/Spring-0/face-censor.git\ncd face-censor\n```\n\n2. Create a virtual environment and activate it:\n```bash\npython -m venv .venv\nsource .venv/bin/activate  # On Windows, use: .venv\\Scripts\\activate\n```\n\n3. Install the required packages:\n```bash\npip install -r requirements.txt\n```\n\n4. Run:\n```bash\npython src/main.py\n```\n\n## Training the Model - Optional\n\nThe project uses the WIDER FACE dataset from Roboflow for training. I have included a pre-trained model, so there is no need to re-train it unless you want to. Here is how:\n\n1. Update this line in `training/training.py` if required:\n```python\ndevice=\"0\"  # Set to \"0\" to utilize GPU, otherwise set to \"cpu\" to utilize CPU\n```\n\n2. Create a `.env` file in the project root with your Roboflow API key:\n```bash\nROBOFLOW_API_KEY=your_api_key_here\n```\n\n3. Run the training script:\n```bash\ncd training\npython3 training.py\n```\n\n## Usage\n\n### API Usage\n```python\n# Face detection model\nfrom models.yolo_detector import YOLOFaceDetector\n\n# Masking methods (no need to import all, just what you want to use)\nfrom masking.text import TextCensor\nfrom masking.emoji import EmojiCensor\nfrom masking.blur import BlurCensor\n\n# Media processor\nfrom processor import MediaProcessor\n\n# Initialize face detector model\ndetector = YOLOFaceDetector()\n```\n### Creating Masking Object\nThis is what determines what effect will be applied to mask the faces.\n\n#### Using Text Masking\n```python\ntext_censor = TextCensor(\n    text=\"HELLO\", # The text to draw on faces\n    draw_background=True, # Control whether to draw solid background behind text\n    background_color=\"white\", # The color of the solid background\n    text_color=\"black\", # The color of the text\n    scale_factor=0.2 # The text size scaling factor, default to 0.5\n)\n```\n#### Using Emoji Masking\n```python\nemoji_censor = EmojiCensor(\n    emoji=\"😁\", # The emoji you want to use to mask faces\n    font=\"seguiemj.ttf\", # The path to the emoji font file, by default uses \"seguiemj.ttf\"\n    scale_factor=1.0 # The emoji size scaling factor in percentage, default to 1.0\n)\n```\n#### Using Blur Masking\n```python\nblur_censor = BlurCensor(\n    blur_factor=71 # The strength of the blur effect, defaults to 99\n)\n```\n\n### Create Media Processor\nAfter creating the masking method object(s), you need to pass it to the `MediaProcessor` constructor like so:\n```python\nprocessor = MediaProcessor(detector, blur_censor)\n```\n\n### Processing Images\n```python\n# Process an image\nprocessor.process_image(\"input.jpg\", \"output.jpg\")\n```\n\n### Processing Videos\n```python\n# Process a video\nprocessor.process_video(\"input.mp4\", \"output.mp4\")\n```\n\n## Demo\n\n### Input Image/Video\n![Input Image/Video](assets/input.jpg)\n\n### Output Image/Video\n#### Blur Masking\n![Output Blur Image/Video](assets/output_blur.jpg)\n\n#### Emoji Masking\n![Output Emoji Image/Video](assets/output_emoji.jpg)\n\n#### Text Masking\n![Output Text Image/Video](assets/output_text.jpg)\n\n## Requirements\n\n- Python 3.8+\n- PyTorch\n- OpenCV\n- Ultralytics YOLOv8\n- Roboflow\n\nSee `requirements.txt` for complete list.\n\n## License\n\nGPU General Public License - see LICENSE file for details.\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## TODO\n\n- [x] Add emoji face masking\n- [ ] Add support for real time streams\n- [x] Add GUI interface\n- [ ] Add partial face censoring (eyes)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-0%2Fface-censor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspring-0%2Fface-censor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-0%2Fface-censor/lists"}