google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://mediapipe.dev
Apache License 2.0
26.73k stars 5.08k forks source link

Image patch preprocessing/normalization for face landmarks #4787

Open markpredigertrinamix opened 12 months ago

markpredigertrinamix commented 12 months ago

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

None

OS Platform and Distribution

Embedded Linux

MediaPipe Tasks SDK version

No response

Task name (e.g. Image classification, Gesture recognition etc.)

Face landmarks

Programming Language and version (e.g. C++, Python, Java)

C++

Describe the actual behavior

Running the face landmarks model standalone on a cropped face patch

Describe the expected behaviour

Applying the correct preprocessing/normalization to the cropped face

Standalone code/steps you may have used to try to get what you need

We are trying to run the face_landmarks_detector.tflite standalone on a 256x256 crop of the face. What are the required preprocessing/normalization steps for the model input? Currently we are normalizing the uint8 image crop to float [0.0 ... 1.0] value range. Is this the correct normalization, or should we use something else?

Other info / Complete Logs

No response

schmidt-sebastian commented 12 months ago

The Tasks library should do all pre-processing on your behalf. Have you tried just providing the original image?

markpredigertrinamix commented 12 months ago

Unfortunately we cannot use the mediapipe libraries due to very strict limitations of our embedded platform. We need to run the face landmarks model standalone and do the pre-/post-processing manually.

kaikaizhu commented 9 months ago

I had the same problem. I want to know, if I only have 256x256 face image, how should I do face landmarks detection. What pretreatment needs to be done? Or if there is any code that runs face_landmarks directly. Thanks a lot!

schmidt-sebastian commented 9 months ago

All of our pre-processing happens here: https://github.com/google/mediapipe/blob/8d57a9e2e815dd11a7434cb764382cc7ce4831a5/mediapipe/tasks/cc/components/processors/image_preprocessing_graph.cc#L67

You would have to look at how the specific tasks handles this graph.