immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
50.35k stars 2.67k forks source link

Facial Recognition is not working - shape mismatch #11778

Closed rahatzamancse closed 2 months ago

rahatzamancse commented 2 months ago

The bug

I am running Immich on an unRAID server with docker-compose.

While starting the face recognition job, I get the following from the log of machine learning docker:

/opt/venv/lib/python3.11/site-packages/huggingface_hub/file_download.py:1212: UserWarning: `local_dir_use_symlinks` parameter is deprecated and will be ignored. The process to download files to a local folder has been updated and do not rely on symlinks anymore. You only need to pass a destination folder as`local_dir`.
For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder.
  warnings.warn(
Fetching 4 files: 100%|██████████| 4/4 [00:03<00:00,  1.25it/s]
2024-08-14 11:33:53.779740322 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {6,512} for output 1333
2024-08-14 11:33:55.613064417 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {7,512} for output 1333
2024-08-14 11:33:58.216946572 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {2,512} for output 1333
2024-08-14 11:34:00.455222668 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {7,512} for output 1333
2024-08-14 11:34:08.754432411 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {2,512} for output 1333
2024-08-14 11:34:09.142175350 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {2,512} for output 1333
2024-08-14 11:34:18.241810641 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {9,512} for output 1333
2024-08-14 11:34:18.661376507 [W:onnxruntime:, execution_frame.cc:879 VerifyOutputSizes] Expected shape from model of {1,512} does not match actual shape of {9,512} for output 1333

The OS that Immich Server is running on

unRAID

Version of Immich Server

v1.112.0

Version of Immich Mobile App

v1.111.0

Platform with the issue

Your docker-compose.yml content

name: immich
services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-openvino
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    # devices:
    #   - /dev/dri:/dev/dri
    # device_cgroup_rules:
    #   - 'c 189:* rmw'
    volumes:
      - model-cache:/cache
      # - /dev/bus/usb:/dev/bus/usb
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: docker.io/redis:6.2-alpine@sha256:328fe6a5822256d065debb36617a8169dbfbd77b797c525288e465f56c1d392b
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    healthcheck:
      test: pg_isready --dbname='${DB_DATABASE_NAME}' || exit 1; Chksum="$$(psql --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
      interval: 5m
      start_period: 5m
    command: ["postgres", "-c" ,"shared_preload_libraries=vectors.so", "-c", 'search_path="$$user", public, vectors', "-c", "logging_collector=on", "-c", "max_wal_size=2GB", "-c", "shared_buffers=512MB", "-c", "wal_compression=on"]
    restart: always

volumes:
  model-cache:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=/mnt/user/photos-immich
DB_DATA_LOCATION=/mnt/user/appdata/postgresql_immich

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
DB_PASSWORD=postgres

REDIS_HOSTNAME=immich_redis

TZ=America/Denver

Reproduction steps

Go to the admin>jobs, and start the face detection process

Relevant log output

No response

Additional information

No response

alextran1502 commented 2 months ago

Look like it is downloading the model, can you wait a bit?

alextran1502 commented 2 months ago

You can ignore the shape mismatch message.

rahatzamancse commented 2 months ago

Look like it is downloading the model, can you wait a bit?

The download finished instantly, I think this is not related to the model downloading problem.

You can ignore the shape mismatch message.

Okay. Let me finish the face detection job and see if it identifies/groups faces.

rahatzamancse commented 2 months ago

Yes, face recognition is working. I also tried with openvino and that also worked.