Overview
This guide walks through installing Iris on your local machine. The installation process includes cloning the repository, downloading AI models, building the Rust binary, and starting the API server.Ensure you’ve completed all Prerequisites before proceeding.
Installation Steps
Clone the Repository
Download the Iris source code from GitHub:Verify the directory structure:Expected output:
Download AI Models
Iris requires two ONNX models from OpenCV Zoo. Use the provided setup script:
What does setup.sh do?
What does setup.sh do?
The script downloads the following models:The script:
setup.sh
- Checks if models already exist (safe to re-run)
- Downloads YuNet face detection model (~360KB)
- Downloads SFace face recognition model (~41MB)
- Places models in the project root directory
Manual model download
Manual model download
If the script fails or you prefer manual installation:Verify downloads:Expected output:
Build the Project
Compile Iris in release mode for optimal performance:Expected output:
First build may take 5-10 minutes as Cargo compiles all dependencies, including OpenCV bindings. Subsequent builds will be faster.
Troubleshooting build errors
Troubleshooting build errors
OpenCV linking errors:Solutions:Solution:
- Verify OpenCV is installed:
pkg-config --modversion opencv4 - Set pkg-config path:
- On macOS with Homebrew:
Configuration
Model Paths
Iris loads models from the project root by default. The paths are defined insrc/face.rs:
src/face.rs
Server Port
The default port is 8080. To change it, editsrc/main.rs:
src/main.rs
Rate Limiting
Iris includes IP-based rate limiting to prevent abuse:src/main.rs
src/main.rs:128-129 based on your needs.
CORS Policy
CORS is configured to allow all origins by default:src/main.rs
Testing the Installation
Health Check
Verify the server is running:Face Comparison Test
Test the/compare endpoint with sample images:
Understanding the response
Understanding the response
- matches: Array of people whose similarity score exceeds threshold (0.363)
- name: Identifier from the request
- probability: Cosine similarity score × 100 (higher = more similar)
- Empty array if no faces detected or no matches above threshold
Request Statistics
Check API usage metrics:Running in Development Mode
For faster compilation during development:Project Structure
Understanding the codebase:src/main.rs
src/main.rs
Core API server with:
- Axum web framework setup
- Rate limiting middleware (5 req/s per IP)
- CORS configuration
/compareendpoint handler/statsand/healthendpoints- Image download and Base64 data URI support
src/face.rs
src/face.rs
Face recognition engine:
FaceEnginestruct managing YuNet detector and SFace recognizer- Model initialization with hardcoded paths
get_embedding()function for face detection and feature extraction- Returns 128-dimensional vectors for similarity comparison
src/models.rs
src/models.rs
Data structures for API requests and responses:
CompareRequest: target image + array of peopleCompareResponse: array of matches with probabilitiesPerson,MatchResult, etc.
src/stats.rs
src/stats.rs
Request tracking:
- Thread-safe request counter
- Requests per second calculation
- Exposed via
/statsendpoint
Environment Variables
Iris does not currently use environment variables. Configuration is done through:- Code modifications (port, rate limits, CORS)
- Model file placement (working directory)
- Cargo.toml (dependency versions)
Performance Optimization
Release Build
Always use release mode for production:- Compiler optimizations (-O3 equivalent)
- Inlining and dead code elimination
- 10-100x faster than debug builds
System Tuning
- Linux
- macOS
Increase file descriptor limits:For persistent changes, edit
/etc/security/limits.conf:Tokio Runtime
Iris uses Tokio withfeatures = ["full"] for async I/O. Adjust worker threads via environment variable:
Security Considerations
Recommended Hardening
- Restrict CORS origins (see Configuration section)
- Enable HTTPS using a reverse proxy (nginx, Caddy)
- Add authentication middleware for API access
- Implement request validation (image size limits, URL allowlisting)
- Run as non-root user in production environments
- Use environment variables for sensitive configuration
Data Privacy
Iris is stateless by design:- Images are processed in RAM only
- No data persists to disk
- Face embeddings are computed and immediately discarded
- No logging of biometric data
This architecture ensures GDPR/HIPAA compliance for biometric data processing.
Updating Iris
To update to the latest version:Troubleshooting
Models not found error
Models not found error
Symptoms:Cause: ONNX models not in working directory.Solution:
Port already in use
Port already in use
Symptoms:Solution:
Image download failures
Image download failures
Symptoms: Empty
matches array for valid faces.Causes:- Network connectivity issues
- Invalid image URLs
- HTTPS certificate errors
- Rate limiting by image host
- Test URLs in browser first
- Use data URIs for local testing
- Check firewall/proxy settings
Rate limit errors (429)
Rate limit errors (429)
Symptoms:Cause: Exceeded 5 requests/second from single IP.Solution:
- Wait 1 second between requests
- Increase quota in
src/main.rs:128 - Use multiple IPs for load testing
Next Steps
API Reference
Learn about available endpoints and request formats
Docker Deployment
Deploy Iris in a containerized environment
Quick Start
Build your first face recognition integration
Architecture
Understand how Iris processes face recognition