No description
Find a file
2025-04-12 16:37:47 +02:00
resources Add example gif 2025-03-29 09:33:18 +01:00
templates Refactoring code 2025-04-12 11:15:13 +02:00
.gitignore Add a basic parameters webpage 2025-04-06 19:08:27 +02:00
LICENSE Add license 2025-03-29 09:36:12 +01:00
main.py Simplified process parameters 2025-04-12 14:45:22 +02:00
README.md Add a note about execution speed. 2025-03-31 20:32:02 +02:00
requirements.txt Use dlib CNN face detector model, add logging 2025-03-31 19:54:37 +02:00
timelapse.py Add back resolution threshold. Improve eye openness detection 2025-04-12 16:37:47 +02:00

Immich Selfie Timelapse Tool

This tool helps create selfie timelapses from your Immich instance.
It uses the powerful machine learning features of Immich to gather all the photographs where a particular individual appears, retrieves the bounding box metadata, and automatically crops and aligns the photos.

Example Image

Example GIF

Features

  • Automatically fetch images featuring a specified individual from your Immich instance.
  • Extract bounding box metadata and crop/align photos using machine learning.
  • Discard photos with low resolution (set by threshold).
  • Discard photos where the subject is viewed from the side.
  • Adds timestamp in the filename for easy chronological ordering.

Setup

  1. Generate an API Key in Immich:

    • Log in to your Immich web UI.
    • Navigate to the API settings (or your profile settings) and generate an API key.
    • Copy the API key for use with the script.
  2. Find the Person ID:

    • In the Immich web UI, view photos sorted by person.
    • When you click on a specific person, check the URL in your browser.
    • The person ID (usually a UUID) is part of the URL. Copy this ID for use in the script.
  3. Install Dlib python library

  4. Download the face detection CNN model

  5. Download the Face Landmark Data:

  6. Install the required python modules from requirements.txt

    • Note that an old version of Numpy is required for compatibility with dlib.

Usage

Run the script from the command line with the required arguments. For example:

python process_faces.py \
  --api-key YOUR_API_KEY \
  --base-url http://your.immich.server:2283/api \
  --person-id YOUR_PERSON_ID \
  --output-folder output

Command-line Arguments

  • --api-key: API key generated from Immich.
  • --base-url: Base URL of your Immich API (e.g., http://192.168.1.123:2283/api).
  • --person-id: The ID of the person (obtained from the Immich web UI).
  • --output-folder: Directory where the aligned face images will be saved (default: output).
  • --padding-percent: Padding added around the face as a percentage (default: 0.3).
  • --resize-width and --resize-height: Dimensions for the output image (default: 512 x 512).
  • --min-face-width and --min-face-height: Minimum acceptable face dimensions (default: 128 x 128).
  • --pose-threshold: Threshold for acceptable head pose.
  • --desired-left-eye: Desired left eye position as a fraction (x y) in the output image (default: 0.35 0.45).
  • --max-workers: Number of parallel processes to use (default: 4).
  • --face-detect-model-paths: Path to the CNN face detector model file (default: mmod_human_face_detector.dat).
  • --landmark-model-path: Path to the face landmark predictor model file (default: shape_predictor_68_face_landmarks.dat).

Additional Notes

  • Ensure that the shape_predictor_68_face_landmarks.dat file is accessible by the script. Update the path if necessary.
  • The tool may require some manual sorting of the output images to achieve the best video effect. In particular, the face landmark detection is not super robust.
  • Execution speed: on my i5 11400, it can process about 2 image per second.
  • I find that a video framerate of 15 fps gives good results.
  • Contributions and improvements are welcome.

License

This project is open source and available under the MIT License.