Face Analysis & Content Moderation
From the course Computer Vision APIs & Applications
Visual Analysis Applications
Face Analysis
Modern APIs can detect faces and analyze attributes:
- Detection: Find faces in images with bounding boxes
- Attributes: Age estimation, expression, pose
- Comparison: Verify if two faces match
- Landmarks: Eye, nose, mouth positions
Content Moderation
// Using OpenAI moderation with vision
const moderation = await openai.moderations.create({
model: "omni-moderation-latest",
input: [
{ type: "image_url", image_url: { url: userUploadedImage } }
],
});
if (moderation.results[0].flagged) {
console.log("Content flagged:", moderation.results[0].categories);
}
Use Cases
E-commerce:
- Auto-tag product images
- Detect counterfeit products
- Generate alt text for accessibility
- Visual search (find similar products)
Healthcare:
- Analyze medical images (with proper compliance)
- Detect anomalies in X-rays and scans
- Document digitization for patient records
Security:
- Monitor video feeds for anomalies
- Detect prohibited items
- Access control with facial verification
Ethical Considerations
- Bias: Face analysis models may perform differently across demographics
- Privacy: Store face data only with explicit consent
- Transparency: Disclose AI analysis to users
- Accuracy: Never use face analysis as sole decision-maker for critical applications
Common Pitfall: Using Face Comparison for Identity Verification Without Liveness
Face comparison APIs (AWS Rekognition CompareFaces, Azure Face API) verify that two photos show the same person — but they do not prevent photo spoofing. An attacker can print a photo of the target and hold it up to the camera. Production identity verification systems pair face comparison with liveness detection (asking users to blink, turn their head, or respond to prompts) to confirm the image is captured from a real person in real time.
Best Practice: Run Content Moderation Before Storing Any User Upload
Never write user-uploaded images to permanent storage before running moderation checks. Establish a two-bucket pattern: write uploads to a temporary "staging" bucket first, run moderation asynchronously, then promote clean images to the "public" bucket. This prevents prohibited content from ever appearing in your main storage:
async function handleUpload(file: File, userId: string) {
const stagingUrl = await uploadToStaging(file, userId); // temp bucket
const moderation = await openai.moderations.create({
model: "omni-moderation-latest",
input: [{ type: "image_url", image_url: { url: stagingUrl } }],
});
if (moderation.results[0].flagged) {
await deleteFromStaging(stagingUrl);
throw new Error("Content policy violation");
}
return await promoteToPublic(stagingUrl); // permanent bucket
}
Named Product Reference: AWS Rekognition Content Moderation
AWS Rekognition's DetectModerationLabels API classifies images into a hierarchical taxonomy of unsafe content categories (explicit nudity, violence, hate symbols, alcohol, drugs) with confidence scores. The API supports both synchronous single-image and asynchronous video analysis. It is widely used in social media platforms, marketplaces, and dating apps to automatically screen user uploads at scale — processing millions of images per day without manual review for the majority.
Key Takeaways
- •Content moderation APIs flag inappropriate images automatically
- •Face analysis detects, compares, and analyzes facial attributes
- •Computer vision enables product tagging, medical imaging, and security
- •Address bias, privacy, and transparency when using face analysis
Progress is kept in this browser only.