A RESTful API built with Node.js, Express, and TensorFlow.js for detecting humans in images using the COCO-SSD model.
- 🎯 Real-time human detection in images
- 🤖 Powered by TensorFlow.js and COCO-SSD model
- 📊 Returns detection confidence scores
- 🔍 Identifies all objects in the image
- 🌐 CORS enabled
- 📝 Simple JSON responses
npm installStart the server:
npm startFor development mode with auto-reload:
npm run devThe server will run on http://localhost:3000 by default.
Analyzes an image and detects if humans are present.
Endpoint: POST /detect-human
Content-Type: multipart/form-data
Parameters:
image(file) - Image file to analyze
Example cURL:
curl -X POST http://localhost:3000/detect-human \
-F "image=@/path/to/your/image.jpg"Response:
{
"result": "detected",
"human_detected": true,
"details": {
"human_count": 2,
"detected_objects": [
{
"class": "person",
"confidence": "87.45%"
},
{
"class": "person",
"confidence": "92.31%"
}
]
}
}Response Fields:
result:"detected"or"not_detected"human_detected: Boolean indicating if humans were founddetails.human_count: Number of humans detecteddetails.detected_objects: Array of all detected objects with confidence scores
Check if the server and model are running properly.
Endpoint: GET /health
curl http://localhost:3000/healthResponse:
{
"status": "OK",
"model_loaded": true,
"port": 3000
}Open http://localhost:3000/test.html in your browser for a user-friendly web interface to test the API.
- JPEG / JPG
- PNG
- GIF
- BMP
Maximum file size: 10MB
- Node.js - Runtime environment
- Express.js - Web framework
- TensorFlow.js - Machine learning library
- COCO-SSD - Object detection model
- Multer - File upload middleware
- Jimp - Image processing
ISC
Contributions are welcome! Please feel free to submit a Pull Request.