# PhotoPrism + MariaDB + TensorFlow

> AI-powered photo management with face recognition.

- Category: Media & Entertainment
- Difficulty: intermediate
- Components: photoprism, mariadb, tensorflow
- Tags: photoprism, photos, ai, face-recognition, gallery
- Source: https://docker.recipes/media/photoprism-complete

## Overview

PhotoPrism is an AI-powered photo management application that leverages TensorFlow for advanced image recognition, automatic tagging, and face detection. Originally developed as a privacy-focused alternative to Google Photos, PhotoPrism processes RAW files, organizes photos by location and date, and uses machine learning to classify images without sending data to external services. The application has gained popularity among photography enthusiasts and privacy-conscious users who want professional-grade photo management capabilities on their own infrastructure.

This stack combines PhotoPrism's AI capabilities with MariaDB's robust database performance and TensorFlow's machine learning processing power. MariaDB serves as the metadata repository, storing image classifications, face recognition data, album information, and user preferences, while TensorFlow handles the computationally intensive tasks of image analysis, object detection, and facial recognition. The integration allows PhotoPrism to maintain fast search capabilities across large photo libraries while performing real-time AI analysis of newly uploaded images.

Photographers, families with large digital photo collections, and organizations requiring private photo hosting will find this combination particularly valuable. The stack is ideal for users who need professional photo management features like RAW processing, GPS-based organization, and intelligent search, but want to maintain complete control over their data. Small creative agencies, photography studios, and tech-savvy households can deploy this to replace cloud photo services while gaining superior AI-powered organization capabilities.

## Features

- TensorFlow-powered automatic image classification and object recognition with over 1000 labels
- Real-time face detection and clustering for organizing photos by people
- RAW file processing support for professional photography formats (CR2, NEF, ARW, DNG)
- GPS-based photo mapping with interactive world map visualization
- Color-based image search and filtering using advanced color analysis
- MariaDB optimized storage with InnoDB buffer pool configuration for fast metadata queries
- WebDAV synchronization for automatic photo backup from mobile devices
- Live photo support with video thumbnail generation and playback

## Use cases

- Photography studios managing client photo collections with AI-powered organization
- Families digitizing and organizing decades of photo archives with automatic face recognition
- Content creators building searchable stock photo libraries with automatic tagging
- Small businesses replacing Google Photos while maintaining AI search capabilities
- Privacy-focused individuals hosting personal photo collections without cloud dependencies
- Creative agencies organizing project assets with location and date-based categorization
- Hobbyist photographers processing and cataloging RAW files with professional tools

## Prerequisites

- Minimum 4GB RAM (8GB recommended) for TensorFlow model processing and image analysis
- Docker and Docker Compose installed with at least 20GB available storage space
- Port 2342 available for PhotoPrism web interface access
- Basic understanding of photo file formats and metadata for optimal configuration
- CPU with adequate processing power for AI model inference (multi-core recommended)
- Environment variables configured: ADMIN_USER, ADMIN_PASSWORD, MYSQL_USER, MYSQL_PASSWORD, MYSQL_ROOT_PASSWORD

## docker-compose.yml

```yaml
services:
  photoprism:
    image: photoprism/photoprism:latest
    security_opt:
      - seccomp:unconfined
      - apparmor:unconfined
    environment:
      - PHOTOPRISM_ADMIN_USER=${ADMIN_USER}
      - PHOTOPRISM_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - PHOTOPRISM_AUTH_MODE=password
      - PHOTOPRISM_SITE_URL=http://localhost:2342/
      - PHOTOPRISM_ORIGINALS_LIMIT=5000
      - PHOTOPRISM_HTTP_COMPRESSION=gzip
      - PHOTOPRISM_LOG_LEVEL=info
      - PHOTOPRISM_READONLY=false
      - PHOTOPRISM_EXPERIMENTAL=false
      - PHOTOPRISM_DISABLE_CHOWN=false
      - PHOTOPRISM_DISABLE_WEBDAV=false
      - PHOTOPRISM_DISABLE_SETTINGS=false
      - PHOTOPRISM_DISABLE_TENSORFLOW=false
      - PHOTOPRISM_DISABLE_FACES=false
      - PHOTOPRISM_DISABLE_CLASSIFICATION=false
      - PHOTOPRISM_DISABLE_RAW=false
      - PHOTOPRISM_RAW_PRESETS=false
      - PHOTOPRISM_JPEG_QUALITY=85
      - PHOTOPRISM_DETECT_NSFW=false
      - PHOTOPRISM_UPLOAD_NSFW=true
      - PHOTOPRISM_DATABASE_DRIVER=mysql
      - PHOTOPRISM_DATABASE_SERVER=mariadb:3306
      - PHOTOPRISM_DATABASE_NAME=photoprism
      - PHOTOPRISM_DATABASE_USER=${MYSQL_USER}
      - PHOTOPRISM_DATABASE_PASSWORD=${MYSQL_PASSWORD}
    working_dir: /photoprism
    volumes:
      - photoprism-originals:/photoprism/originals
      - photoprism-storage:/photoprism/storage
    ports:
      - "2342:2342"
    depends_on:
      - mariadb
    networks:
      - photoprism-network
    restart: unless-stopped

  mariadb:
    image: mariadb:10.11
    security_opt:
      - seccomp:unconfined
      - apparmor:unconfined
    command: --innodb-buffer-pool-size=512M --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=120
    environment:
      - MARIADB_AUTO_UPGRADE=1
      - MARIADB_INITDB_SKIP_TZINFO=1
      - MARIADB_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MARIADB_DATABASE=photoprism
      - MARIADB_USER=${MYSQL_USER}
      - MARIADB_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - mariadb-data:/var/lib/mysql
    networks:
      - photoprism-network
    restart: unless-stopped

volumes:
  photoprism-originals:
  photoprism-storage:
  mariadb-data:

networks:
  photoprism-network:
    driver: bridge
```

## .env

```bash
# PhotoPrism
ADMIN_USER=admin
ADMIN_PASSWORD=secure_admin_password
MYSQL_ROOT_PASSWORD=secure_root_password
MYSQL_USER=photoprism
MYSQL_PASSWORD=secure_mysql_password
```

## Usage notes

- Web UI at http://localhost:2342
- Login with admin credentials
- Upload photos via web or WebDAV
- AI indexing runs automatically
- Face recognition enabled

## Troubleshooting

- PhotoPrism shows 'TensorFlow not available' error: Ensure PHOTOPRISM_DISABLE_TENSORFLOW=false and container has sufficient memory allocated
- Face recognition not working after photo upload: Check that PHOTOPRISM_DISABLE_FACES=false and run manual indexing from Settings > Library
- MariaDB connection refused during startup: Wait for MariaDB container to fully initialize (can take 30-60 seconds on first run) before PhotoPrism connects
- High CPU usage during photo indexing: Normal behavior when TensorFlow processes new images, reduce concurrent workers in advanced settings if needed
- RAW files not displaying thumbnails: Verify PHOTOPRISM_DISABLE_RAW=false and ensure sufficient storage space for thumbnail generation
- Database connection errors after restart: Check that mariadb-data volume persists and MARIADB_AUTO_UPGRADE=1 is set for schema updates

