Skip to content

Instantly share code, notes, and snippets.

@9Dave9
Created February 3, 2026 12:39
Show Gist options
  • Select an option

  • Save 9Dave9/6e723f3c5faff5eb70b0b1395942c893 to your computer and use it in GitHub Desktop.

Select an option

Save 9Dave9/6e723f3c5faff5eb70b0b1395942c893 to your computer and use it in GitHub Desktop.
deep emo endpoint docuemtation
{
"openapi": "3.1.0",
"info": {
"title": "Deep-Emo API",
"description": "\n## Human Attribute and Emotion Identifier API\n\nThis API provides facial attribute analysis using the DeepFace library.\nIt can detect and analyze:\n\n- **Age**: Estimated age in years\n- **Gender**: Male/Female classification with confidence scores\n- **Race/Ethnicity**: Classification across multiple categories\n- **Emotion**: Detection of facial expressions (happy, sad, angry, etc.)\n- **Nudity Detection**: Body-part classification with covered/exposed labels\n\n### Image Input Formats\n\nThe API accepts images in the following formats:\n1. **File Upload**: Direct file upload via multipart form\n2. **Base64**: Base64-encoded image string (with or without data URL prefix)\n\n### Image Optimization\n\nImages are automatically optimized to reduce size while preserving\nessential details for accurate analysis. You can control optimization\nparameters or disable it entirely.\n\n### Token Counting\n\nEach response includes token count information for both input (image)\nand output (results). This is informational and helps estimate\ncomputational cost.\n ",
"contact": {
"name": "Deep-Emo Support",
"email": "support@deep-emo.example.com"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
},
"version": "1.0.0"
},
"paths": {
"/health": {
"get": {
"tags": [
"Utilities"
],
"summary": "Health Check",
"description": "Check if the API service is running and healthy.",
"operationId": "health_check_health_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HealthResponse"
}
}
}
}
}
}
},
"/analyze/upload": {
"post": {
"tags": [
"Analysis"
],
"summary": "Analyze Image via File Upload",
"description": "Upload an image file for facial attribute analysis.\n\nSupported formats: JPEG, PNG, GIF, BMP, WebP\n\nThe image will be automatically optimized unless `optimize=false` is specified.\nUses robust face detection with automatic backend fallback.",
"operationId": "analyze_upload_analyze_upload_post",
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Body_analyze_upload_analyze_upload_post"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CombinedAnalysisResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/analyze/base64": {
"post": {
"tags": [
"Analysis"
],
"summary": "Analyze Image via Base64",
"description": "Send a base64-encoded image for facial attribute analysis.\n\nThe image can be sent as:\n- Plain base64 string\n- Data URL format: `data:image/jpeg;base64,...`\n\nThis endpoint is useful for web applications that already have\nimages in memory as base64 strings.\nUses robust face detection with automatic backend fallback.",
"operationId": "analyze_base64_analyze_base64_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Base64ImageRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CombinedAnalysisResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/optimize": {
"post": {
"tags": [
"Utilities"
],
"summary": "Optimize Image",
"description": "Optimize an image without performing analysis.\n\nThis endpoint is useful when you want to prepare an image\nfor analysis or reduce its size for transmission.\n\nReturns the optimized image as base64 along with size information.",
"operationId": "optimize_image_endpoint_optimize_post",
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Body_optimize_image_endpoint_optimize_post"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ImageOptimizationResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/nudity/upload": {
"post": {
"tags": [
"Analysis"
],
"summary": "Detect Nudity via File Upload",
"description": "Upload an image file for nudity and body-part detection.\n\n Supported formats: JPEG, PNG, GIF, BMP, WebP",
"operationId": "nudity_upload_nudity_upload_post",
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Body_nudity_upload_nudity_upload_post"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NudityResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/nudity/base64": {
"post": {
"tags": [
"Analysis"
],
"summary": "Detect Nudity via Base64",
"description": "Send a base64-encoded image for nudity and body-part detection.\n\n The image can be sent as:\n - Plain base64 string\n - Data URL format: `data:image/jpeg;base64,...`",
"operationId": "nudity_base64_nudity_base64_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Base64NudityImageRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NudityResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/nudity/video": {
"post": {
"tags": [
"Analysis"
],
"summary": "Detect Nudity in Video",
"description": "Send a base64-encoded video for nudity and body-part detection.\n\n The video can be sent as:\n - Plain base64 string\n - Data URL format: `data:video/mp4;base64,...`",
"operationId": "nudity_video_nudity_video_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VideoNudityRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NudityResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"AnalysisResponse": {
"properties": {
"success": {
"type": "boolean",
"title": "Success",
"description": "Whether the analysis was successful"
},
"data": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"title": "Data",
"description": "Analysis results"
},
"error": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Error",
"description": "Error message if analysis failed"
},
"token_info": {
"$ref": "#/components/schemas/TokenInfo",
"description": "Token count information"
},
"image_info": {
"$ref": "#/components/schemas/ImageInfo",
"description": "Image processing information"
}
},
"type": "object",
"required": [
"success",
"token_info",
"image_info"
],
"title": "AnalysisResponse",
"description": "Response model for analysis endpoints.",
"examples": [
{
"data": {
"faces": [
{
"age": {
"estimated_age": 28
},
"emotion": {
"confidence_scores": {
"angry": 1,
"disgust": 0.5,
"fear": 0.5,
"happy": 85,
"neutral": 10,
"sad": 2,
"surprise": 1
},
"dominant": "happy"
},
"face_id": 1,
"gender": {
"confidence_scores": {
"Man": 4.5,
"Woman": 95.5
},
"dominant": "Woman"
},
"race": {
"confidence_scores": {
"asian": 10,
"black": 5,
"indian": 1.5,
"latino hispanic": 0.5,
"middle eastern": 3,
"white": 80
},
"dominant": "white"
},
"region": {
"h": 200,
"w": 200,
"x": 100,
"y": 50
}
}
],
"summary": {
"analysis_performed": [
"age",
"gender",
"race",
"emotion"
],
"total_faces": 1
}
},
"image_info": {
"faces_detected": 1,
"optimized_size_bytes": 51200,
"original_size_bytes": 102400
},
"success": true,
"token_info": {
"input_tokens": 1024,
"output_tokens": 256
}
}
]
},
"Base64ImageRequest": {
"properties": {
"image": {
"type": "string",
"title": "Image",
"description": "Base64-encoded image string (with or without data URL prefix)"
},
"actions": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Actions",
"description": "List of analyses to perform",
"default": [
"age",
"gender",
"race",
"emotion"
]
},
"enforce_detection": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Enforce Detection",
"description": "If True, raise error when no face is detected. Default False for robustness.",
"default": false
},
"detector_backend": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Detector Backend",
"description": "Face detection backend: retinaface (most accurate), mtcnn, opencv (fastest), ssd, dlib",
"default": "retinaface"
},
"try_all_backends": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Try All Backends",
"description": "If True, tries multiple face detection backends on failure for better robustness",
"default": true
},
"optimize": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Optimize",
"description": "Whether to optimize the image before analysis",
"default": true
},
"max_dimension": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Max Dimension",
"description": "Maximum dimension for image optimization",
"default": 1024
},
"quality": {
"anyOf": [
{
"type": "integer",
"maximum": 100,
"minimum": 1
},
{
"type": "null"
}
],
"title": "Quality",
"description": "JPEG quality for optimization (1-100)",
"default": 85
},
"nudity_threshold": {
"anyOf": [
{
"type": "number",
"maximum": 0.9,
"minimum": 0.1
},
{
"type": "null"
}
],
"title": "Nudity Threshold",
"description": "Confidence threshold for nudity detection",
"default": 0.7
}
},
"type": "object",
"required": [
"image"
],
"title": "Base64ImageRequest",
"description": "Request model for base64-encoded image analysis.",
"examples": [
{
"actions": [
"age",
"gender",
"race",
"emotion"
],
"detector_backend": "retinaface",
"enforce_detection": false,
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRg...",
"max_dimension": 1024,
"nudity_threshold": 0.7,
"optimize": true,
"quality": 85,
"try_all_backends": true
}
]
},
"Base64NudityImageRequest": {
"properties": {
"image": {
"type": "string",
"title": "Image",
"description": "Base64-encoded image string (with or without data URL prefix)"
},
"nudity_threshold": {
"anyOf": [
{
"type": "number",
"maximum": 0.9,
"minimum": 0.1
},
{
"type": "null"
}
],
"title": "Nudity Threshold",
"description": "Confidence threshold for nudity detection",
"default": 0.7
}
},
"type": "object",
"required": [
"image"
],
"title": "Base64NudityImageRequest",
"description": "Request model for base64-encoded image nudity detection.",
"examples": [
{
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRg...",
"nudity_threshold": 0.7
}
]
},
"Body_analyze_upload_analyze_upload_post": {
"properties": {
"file": {
"type": "string",
"format": "binary",
"title": "File",
"description": "Image file to analyze"
},
"actions": {
"type": "string",
"title": "Actions",
"description": "Comma-separated list of analyses to perform",
"default": "age,gender,race,emotion"
},
"enforce_detection": {
"type": "boolean",
"title": "Enforce Detection",
"description": "If True, raise error when no face is detected. Default False for robustness.",
"default": false
},
"detector_backend": {
"type": "string",
"title": "Detector Backend",
"description": "Primary face detection backend (retinaface, mtcnn, opencv, ssd, dlib)",
"default": "retinaface"
},
"try_all_backends": {
"type": "boolean",
"title": "Try All Backends",
"description": "If True, tries multiple backends on failure for better robustness",
"default": true
},
"optimize": {
"type": "boolean",
"title": "Optimize",
"description": "Whether to optimize the image",
"default": true
},
"max_dimension": {
"type": "integer",
"title": "Max Dimension",
"description": "Maximum dimension for optimization",
"default": 1024
},
"quality": {
"type": "integer",
"maximum": 100,
"minimum": 1,
"title": "Quality",
"description": "JPEG quality for optimization",
"default": 85
},
"nudity_threshold": {
"type": "number",
"maximum": 0.9,
"minimum": 0.1,
"title": "Nudity Threshold",
"description": "Confidence threshold for nudity detection",
"default": 0.7
}
},
"type": "object",
"required": [
"file"
],
"title": "Body_analyze_upload_analyze_upload_post"
},
"Body_nudity_upload_nudity_upload_post": {
"properties": {
"file": {
"type": "string",
"format": "binary",
"title": "File",
"description": "Image file to analyze"
},
"nudity_threshold": {
"type": "number",
"maximum": 0.9,
"minimum": 0.1,
"title": "Nudity Threshold",
"description": "Confidence threshold for nudity detection",
"default": 0.7
}
},
"type": "object",
"required": [
"file"
],
"title": "Body_nudity_upload_nudity_upload_post"
},
"Body_optimize_image_endpoint_optimize_post": {
"properties": {
"file": {
"type": "string",
"format": "binary",
"title": "File",
"description": "Image file to optimize"
},
"max_dimension": {
"type": "integer",
"title": "Max Dimension",
"description": "Maximum dimension for optimization",
"default": 1024
},
"quality": {
"type": "integer",
"maximum": 100,
"minimum": 1,
"title": "Quality",
"description": "JPEG quality for optimization",
"default": 85
}
},
"type": "object",
"required": [
"file"
],
"title": "Body_optimize_image_endpoint_optimize_post"
},
"CombinedAnalysisResponse": {
"properties": {
"analysis": {
"$ref": "#/components/schemas/AnalysisResponse",
"description": "DeepFace analysis response"
},
"nudity_detection": {
"$ref": "#/components/schemas/NudityResponse",
"description": "Nudity detection response"
}
},
"type": "object",
"required": [
"analysis",
"nudity_detection"
],
"title": "CombinedAnalysisResponse",
"description": "Combined response for face analysis and nudity detection."
},
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"HealthResponse": {
"properties": {
"status": {
"type": "string",
"title": "Status",
"description": "Service status"
},
"message": {
"type": "string",
"title": "Message",
"description": "Status message"
}
},
"type": "object",
"required": [
"status",
"message"
],
"title": "HealthResponse",
"description": "Health check response."
},
"ImageInfo": {
"properties": {
"faces_detected": {
"type": "integer",
"title": "Faces Detected",
"description": "Number of faces detected in the image"
},
"original_size_bytes": {
"type": "integer",
"title": "Original Size Bytes",
"description": "Original image size in bytes"
},
"optimized_size_bytes": {
"type": "integer",
"title": "Optimized Size Bytes",
"description": "Optimized image size in bytes"
}
},
"type": "object",
"required": [
"faces_detected",
"original_size_bytes",
"optimized_size_bytes"
],
"title": "ImageInfo",
"description": "Image information after processing."
},
"ImageOptimizationResponse": {
"properties": {
"success": {
"type": "boolean",
"title": "Success",
"description": "Whether optimization was successful"
},
"original_size_bytes": {
"type": "integer",
"title": "Original Size Bytes",
"description": "Original image size"
},
"optimized_size_bytes": {
"type": "integer",
"title": "Optimized Size Bytes",
"description": "Optimized image size"
},
"compression_ratio": {
"type": "number",
"title": "Compression Ratio",
"description": "Compression ratio achieved"
},
"optimized_image_base64": {
"type": "string",
"title": "Optimized Image Base64",
"description": "Optimized image as base64"
},
"image_info": {
"additionalProperties": true,
"type": "object",
"title": "Image Info",
"description": "Information about the optimized image"
}
},
"type": "object",
"required": [
"success",
"original_size_bytes",
"optimized_size_bytes",
"compression_ratio",
"optimized_image_base64",
"image_info"
],
"title": "ImageOptimizationResponse",
"description": "Response for image optimization endpoint."
},
"NudityBodyPart": {
"properties": {
"body_part": {
"type": "string",
"title": "Body Part",
"description": "Detected body part name"
},
"coverage": {
"type": "string",
"title": "Coverage",
"description": "Coverage classification (covered/exposed)"
},
"max_score": {
"type": "number",
"title": "Max Score",
"description": "Maximum confidence score for this body part"
}
},
"type": "object",
"required": [
"body_part",
"coverage",
"max_score"
],
"title": "NudityBodyPart",
"description": "Detected body part with coverage classification."
},
"NudityData": {
"properties": {
"summary": {
"$ref": "#/components/schemas/NuditySummary",
"description": "Nudity detection summary"
},
"detections": {
"anyOf": [
{
"items": {
"$ref": "#/components/schemas/NudityDetection"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Detections",
"description": "List of detections (image)"
},
"frames": {
"anyOf": [
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Frames",
"description": "Frame-level detections (video)"
}
},
"type": "object",
"required": [
"summary"
],
"title": "NudityData",
"description": "Nudity detection payload."
},
"NudityDetection": {
"properties": {
"label": {
"type": "string",
"title": "Label",
"description": "Raw label from nudity model"
},
"body_part": {
"type": "string",
"title": "Body Part",
"description": "Normalized body part name"
},
"coverage": {
"type": "string",
"title": "Coverage",
"description": "Coverage classification (covered/exposed)"
},
"score": {
"type": "number",
"title": "Score",
"description": "Confidence score for the detection"
},
"box": {
"additionalProperties": {
"type": "integer"
},
"type": "object",
"title": "Box",
"description": "Bounding box coordinates"
}
},
"type": "object",
"required": [
"label",
"body_part",
"coverage",
"score",
"box"
],
"title": "NudityDetection",
"description": "Nudity detection metadata."
},
"NudityResponse": {
"properties": {
"success": {
"type": "boolean",
"title": "Success",
"description": "Whether the analysis was successful"
},
"data": {
"anyOf": [
{
"$ref": "#/components/schemas/NudityData"
},
{
"type": "null"
}
],
"description": "Nudity detection data"
},
"error": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Error",
"description": "Error message if analysis failed"
},
"media_info": {
"additionalProperties": true,
"type": "object",
"title": "Media Info",
"description": "Media metadata"
}
},
"type": "object",
"required": [
"success",
"media_info"
],
"title": "NudityResponse",
"description": "Response model for nudity endpoints."
},
"NuditySummary": {
"properties": {
"contains_nudity": {
"type": "boolean",
"title": "Contains Nudity",
"description": "Whether nudity was detected above threshold"
},
"nudity_confidence_threshold": {
"type": "number",
"title": "Nudity Confidence Threshold",
"description": "Threshold used for nudity detection"
},
"total_detections": {
"type": "integer",
"title": "Total Detections",
"description": "Total number of detections"
},
"detected_body_parts": {
"items": {
"$ref": "#/components/schemas/NudityBodyPart"
},
"type": "array",
"title": "Detected Body Parts",
"description": "Detected body parts"
},
"total_frames": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Total Frames",
"description": "Total frames in video"
},
"frames_analyzed": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Frames Analyzed",
"description": "Number of frames analyzed"
},
"frame_interval": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Frame Interval",
"description": "Frame interval for analysis"
}
},
"type": "object",
"required": [
"contains_nudity",
"nudity_confidence_threshold",
"total_detections",
"detected_body_parts"
],
"title": "NuditySummary",
"description": "Summary of nudity detection results."
},
"TokenInfo": {
"properties": {
"input_tokens": {
"type": "integer",
"title": "Input Tokens",
"description": "Number of input tokens (image representation)"
},
"output_tokens": {
"type": "integer",
"title": "Output Tokens",
"description": "Number of output tokens (result representation)"
}
},
"type": "object",
"required": [
"input_tokens",
"output_tokens"
],
"title": "TokenInfo",
"description": "Token information for the request."
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
},
"VideoNudityRequest": {
"properties": {
"video": {
"type": "string",
"title": "Video",
"description": "Base64-encoded video (data URL or plain base64)"
},
"frame_interval": {
"anyOf": [
{
"type": "integer",
"maximum": 60,
"minimum": 1
},
{
"type": "null"
}
],
"title": "Frame Interval",
"description": "Analyze every Nth frame",
"default": 20
},
"max_frames": {
"anyOf": [
{
"type": "integer",
"maximum": 200,
"minimum": 1
},
{
"type": "null"
}
],
"title": "Max Frames",
"description": "Maximum frames to analyze",
"default": 50
},
"nudity_threshold": {
"anyOf": [
{
"type": "number",
"maximum": 0.9,
"minimum": 0.1
},
{
"type": "null"
}
],
"title": "Nudity Threshold",
"description": "Confidence threshold for nudity detection",
"default": 0.7
}
},
"type": "object",
"required": [
"video"
],
"title": "VideoNudityRequest",
"description": "Request model for nudity detection in video."
}
}
},
"tags": [
{
"name": "Analysis",
"description": "Facial attribute analysis endpoints"
},
{
"name": "Utilities",
"description": "Utility endpoints for image processing and health checks"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment