|
--- |
|
title: Try |
|
emoji: π₯ |
|
colorFrom: pink |
|
colorTo: gray |
|
sdk: gradio |
|
sdk_version: 4.14.0 |
|
app_file: app.py |
|
pinned: false |
|
license: artistic-2.0 |
|
--- |
|
|
|
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |
|
|
|
--- |
|
|
|
--- |
|
title: Try |
|
emoji: π₯ |
|
colorFrom: pink |
|
colorTo: gray |
|
sdk: gradio |
|
sdk_version: 4.14.0 |
|
app_file: app.py |
|
pinned: false |
|
license: artistic-2.0 |
|
--- |
|
|
|
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |
|
|
|
|
|
# Christmas |
|
|
|
# Image Processor |
|
|
|
## Overview |
|
|
|
The `ImageProcessor` class is designed to overlay graphical gadgets on detected faces in an image. Using a facial detection model, it identifies faces and relevant keypoints (like the nose) and overlays pre-defined gadgets (like hats or other accessories) at appropriate positions on the face. |
|
|
|
## Dependencies |
|
|
|
- Python 3.x |
|
- OpenCV (`cv2`) |
|
- NumPy |
|
- MediaPipe |
|
|
|
To install these dependencies, run: |
|
|
|
```bash |
|
pip install numpy opencv-python mediapipe |
|
``` |
|
|
|
|
|
## Setup |
|
|
|
Ensure all dependencies are installed. |
|
Place the ImageProcessor script in your project directory. |
|
Download the gadgets folder. You can add your own. Please make sure you adapt the code if you are doing so. The code is not super robust yet. |
|
|
|
```bash |
|
from prototype import ImageProcessor |
|
|
|
import cv2 |
|
import mediapipe |
|
|
|
# Load your image |
|
image = cv2.imread('/path/to/your/image.jpg') |
|
|
|
# Specify the folder containing your gadgets |
|
folder_path = 'gadgets/' |
|
|
|
model = mediapipe.solutions.face_detection.FaceDetection(model_selection=1, min_detection_confidence=0.8) |
|
|
|
# Create an instance of the ImageProcessor |
|
processor = ImageProcessor(image, folder_path, model) |
|
processor.detect_and_overlay(write = True, output = "my_edited_image") |
|
``` |
|
|
|
|
|
|