Documentation Index
Fetch the complete documentation index at: https://ailabtools.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Frontend Validation Requirements
Before calling the Hairstyle Processing API, the frontend should perform the following validations:- Image Resolution and Size: Ensure the image meets the API’s resolution and file size requirements for optimal processing quality.
- Face Detection: Verify the presence of a face, the number of faces, the face-to-image ratio, and that the face’s angle meets the required standards.
Specific Validation Details
1. Face and Face-to-Image Ratio Validation
- No Face or Multiple Faces: If no face or multiple faces are detected in the image, the frontend should return an error message, prompting the user to retake or re-upload a suitable photo.
- Non-compliant Face-to-Image Ratio: If the face occupies less than the specified percentage of the image (typically 10%), crop the image at the frontend to meet the required face-to-image ratio.
2. Validation Method
To accomplish the validations above, the frontend can use the Facial Landmarks API to obtain key face data for assessing face count, face-to-image ratio, and face angle.3. Validation Criteria
-
Face Count:
face_num == 0: No face detected, return an error.face_num != 1: Multiple faces detected, return an error.
-
Face-to-Image Ratio:
- Calculation formula: (
location.width*location.height) / (image.width*image.height) >0.1 - If the ratio is less than
0.1, it does not meet the requirement. Using thelocationvalues forleft,top,width, andheightand the overall image dimensions, determine the appropriate crop area to adjust the face-to-image ratio.
- Calculation formula: (
-
Face Angle:
- Validation criteria: If any criterion is not met, return an error message, prompting the user to retake or re-upload the photo.
- The absolute value of
angle.yawshould be less than30 - The absolute value of
angle.pitchshould be less than30 - The absolute value of
angle.rollshould be less than30
- The absolute value of
- Validation criteria: If any criterion is not met, return an error message, prompting the user to retake or re-upload the photo.

