本帖最后由 kszyd 于 2025-1-15 13:58 編輯
之前發(fā)了一篇用photoprism搭建相冊管理的帖子,里面含了基礎(chǔ)環(huán)境安裝,詳細(xì)請見:樹莓派4B打造家用NAS備份手機(jī)照片(把大象裝進(jìn)冰箱系列1)。
但由于樹莓派本身配置低,導(dǎo)致photoprism實(shí)際應(yīng)用體驗(yàn)不好。本次嘗試immich(immich項(xiàng)目地址),體驗(yàn)整體要好很多。基礎(chǔ)環(huán)境仍然是樹莓派4B,裝了OMV,安裝了OMV-Compose插件,通過此插件將immich鏡像部署上。以下是安裝過程:
1、從compose插件-文件-新建,添加應(yīng)用鏡像;1)復(fù)制/導(dǎo)入docker-compose.yml文件內(nèi)容,2)復(fù)制/導(dǎo)入.env文件內(nèi)容;
2、以下是docker-compose.yml原文內(nèi)容,需要做如下更改:1)將兩處ghcr.io替換成ghcr.nju.edu.cn國內(nèi)源,將兩處docker.io替換成docker.m.daocloud.io國內(nèi)源;
2)在- ${UPLOAD_LOCATION}:/usr/src/app/upload 這行下面新增一行外部圖庫路徑,可用于已有圖庫的數(shù)據(jù)加載。(真實(shí)圖庫路徑,本人圖片存放在以下路徑)- /mnt/disk1/old:/media/disk2/new:ro (此路徑是系統(tǒng)真實(shí)路徑,后續(xù)添加外部圖庫時(shí)需要輸入此路徑,ro表示只讀)。
3)替換 - model-cache:/cache 此行為本地大模型加載映射路徑;如本人把git下來的大模型數(shù)據(jù)放在了./mnt/model-cache下面,完整代碼就是:- ./mnt/model-cache:/cache #默認(rèn)加載模型數(shù)據(jù)是從國外鏡像站加載會很慢,可從國內(nèi)鏡像站git到本地,復(fù)制到此目錄下。大模型涉及兩類一是中文搜索二是人臉識別,系統(tǒng)默認(rèn)模型不支持中文語義搜索圖片,可用XLM-Roberta-Large-Vit-B-16Plus替換,人臉識別模型有buffalo_l(系統(tǒng)默認(rèn))和antelopev2(這個(gè)模型大家都說好),將下載或git下來的數(shù)據(jù)分別存放在/mnt/model-cache/clip/XLM-Roberta-Large-Vit-B-16Plus和/mnt/model-cache/facial-recognition/buffalo_l或antelopev2模型數(shù)據(jù),clip和facial-recognition這兩個(gè)文件夾需自己創(chuàng)建,這一步必須有!系統(tǒng)加載模型數(shù)據(jù)的時(shí)候會自動從這兩個(gè)文件夾下查找。
4)將最后volumes: model-cache: 這兩行刪除。
docker-compose.yml原文內(nèi)容:
- #
- # WARNING: Make sure to use the docker-compose.yml of the current release:
- #
- # https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
- #
- # The compose file on main may not be compatible with the latest release.
- #
- name: immich
- services:
- immich-server:
- container_name: immich_server
- image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
- # extends:
- # file: hwaccel.transcoding.yml
- # service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
- volumes:
- # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
- - ${UPLOAD_LOCATION}:/usr/src/app/upload
- - /etc/localtime:/etc/localtime:ro
- env_file:
- - .env
- ports:
- - '2283:2283'
- depends_on:
- - redis
- - database
- restart: always
- healthcheck:
- disable: false
- 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}-cuda
- image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
- # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
- # file: hwaccel.ml.yml
- # service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
- volumes:
- - model-cache:/cache
- env_file:
- - .env
- restart: always
- healthcheck:
- disable: false
- redis:
- container_name: immich_redis
- image: docker.io/redis:6.2-alpine@sha256:905c4ee67b8e0aa955331960d2aa745781e6bd89afc44a8584bfd13bc890f0ae
- 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
- environment:
- POSTGRES_PASSWORD: ${DB_PASSWORD}
- POSTGRES_USER: ${DB_USERNAME}
- POSTGRES_DB: ${DB_DATABASE_NAME}
- POSTGRES_INITDB_ARGS: '--data-checksums'
- volumes:
- # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
- - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
- healthcheck:
- test: >-
- pg_isready --dbname="${POSTGRES_DB}" --username="${POSTGRES_USER}" || exit 1;
- Chksum="$(psql --dbname="${POSTGRES_DB}" --username="${POSTGRES_USER}" --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_interval: 30s
- 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:
復(fù)制代碼 3、以下是env環(huán)境文件,需做如下更改:
1)將 UPLOAD_LOCATION=./library 此行是手機(jī)上傳照片所用路徑,如本人改成了 UPLOAD_LOCATION=/mnt/disk3/upload
2)像數(shù)據(jù)庫文件占用空間不大,可不做變動。
- # 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=./library
- # The location where your database files are stored
- DB_DATA_LOCATION=./postgres
- # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
- # TZ=Etc/UTC
- # The Immich version to use. You can pin this to a specific version like "v1.71.0"
- IMMICH_VERSION=release
- # Connection secret for postgres. You should change it to a random password
- # Please use only the characters `A-Za-z0-9`, without special characters or spaces
- DB_PASSWORD=postgres
- # The values below this line do not need to be changed
- ###################################################################################
- DB_USERNAME=postgres
- DB_DATABASE_NAME=immich
復(fù)制代碼 4、做完以上配置,immich應(yīng)該能正常運(yùn)行了。
以下是在部署過程中遇到的問題及解決辦法:
1、如加載不成功,可將docker-compose.yml 內(nèi) -.env 部分改成 -immich.env,(在omv-compose下yml和env環(huán)境文件名稱需一致,本人創(chuàng)建此應(yīng)用時(shí)將此應(yīng)用命名為了immich.yml)。
2、進(jìn)入immich應(yīng)用后地圖顯示英文問題,可參考如下:地圖顯示中文
3、反向地理編碼顯示英文問題,可參考如下:反向地理編碼顯示中文,需要認(rèn)真查看此貼下面的網(wǎng)友回復(fù)。
4、大模型加載是否成功,要用portainer查看immich-machine-learning日志是否有報(bào)錯(cuò)。在用antelopev2模型進(jìn)行人臉檢索時(shí)由于樹莓派配置不足導(dǎo)致任務(wù)失敗,換成buffalo_l則運(yùn)行正常。尤其是在剛部署上進(jìn)行檢索和人臉識別任務(wù)時(shí)一定要查看immich-machine-learning運(yùn)行日志,從應(yīng)用頁面是看不到模型運(yùn)行情況的。
遺留問題:反向地理編碼數(shù)據(jù)不足導(dǎo)致有些區(qū)域仍顯示不正常,此問題還沒解決,有類似經(jīng)驗(yàn)的朋友可留言討論!
|