Cortex AI Gallery is a sophisticated, AI-powered media management system designed for high-performance indexing, searching, and organizing of personal photo and video collections. It combines a modern FastAPI backend with a high-fidelity Flutter mobile frontend.
- Face Analysis & Clustering: Uses
InsightFacefor industrial-grade face detection, age/gender estimation, and automatic person grouping usingDBSCANclustering. - Natural Language Search: Implements
Salesforce/BLIPfor automatic image captioning, enabling you to search your gallery using descriptive text (e.g., "mountain sunset"). - Efficient Media Pipeline: Dual-stage upload with pre-flight hash checks to avoid duplicates and a background worker system for non-blocking AI processing.
- Modular Architecture: Clean, enterprise-ready folder structure separating API routes, database logic, and AI services.
- Smart Thumbnails: Automatic generation of optimized thumbnails for both images and videos.
- Fluid User Experience: Built with Flutter for a smooth, native feel across mobile platforms.
- Smart Gallery: Paginated "lazy loading" of media to minimize data usage and maximize performance.
- People Discovery: Auto-generated profiles for detected persons, allowing you to filter your gallery by individuals.
- Advanced Filters: Combine text search, person filters, and demographic data (age/gender) to find exactly what you're looking for.
Cortex-AI-Gallery/
├── backend/ # FastAPI Application
│ ├── app/
│ │ ├── api/ # API Route definitions
│ │ ├── core/ # Configuration & Global settings
│ │ ├── db/ # Database initialization & Session management
│ │ ├── models/ # Pydantic schemas for request/response
│ │ ├── services/ # AI logic, Workers, & Media processing
│ │ └── main.py # Application entry point & Lifespan
│ ├── requirements.txt # Python dependencies
│ └── .env.example # Environment variable template
├── frontend/ # Flutter Mobile App
│ ├── lib/
│ │ ├── models/ # Data models
│ │ ├── providers/ # State management
│ │ ├── screens/ # UI Pages
│ │ ├── services/ # API integration layer
│ │ └── widgets/ # Reusable UI components
│ └── pubspec.yaml # Flutter configuration
└── README.md # Main Documentation (You are here)
- Navigate to backend:
cd backend - Install Dependencies:
Note: Requires Python 3.9+ and PyTorch for AI features.
pip install -r requirements.txt
- Configure Environment:
cp .env.example .env # Edit .env to adjust ports or storage paths if needed - Run the Server:
The API will be available at
python -m app.main
http://localhost:8000with interactive docs at/docs.
- Navigate to frontend:
cd frontend - Install Packages:
flutter pub get
- Configure API:
Open
lib/services/api_service.dartand update_baseUrlto point to your backend IP. - Launch App:
flutter run
- Backend: Python, FastAPI, SQLite (aiosqlite), InsightFace, BLIP (Transformers), PyTorch, OpenCV, Scikit-learn.
- Frontend: Dart, Flutter, Dio (HTTP client).
- Core Logic: Multi-process/Multi-thread execution pools for handling heavy AI workloads.
This project is licensed under the MIT License - see the LICENSE file for details.