photoprism初体验

  |   0 评论   |   0 浏览

背景

photoprism是一个AI驱动的照片管理工具。其基于go和TensorFlow开发,支持人脸识别、元数据提取和强大的搜索。[1]

photoprism保证不会分享个人隐私信息给Google, Amazon, Microsoft or Apple公司。[2]

docker compose初体验

官方推荐使用docker compose的方式,部署在自己私有的服务器上,支持Mac、Linux和Windows环境。[3]

系统要求

硬件:2核,3GB物理内存,64位操作系统。推荐使用SSD硬盘。
数据库:MariaDB 10.5.12+ (推荐), SQLite 3。
浏览器:支持PWA的浏览器,如Chrome、Safari、Firefox和Edge。

docker compose安装

wget https://dl.photoprism.app/docker/docker-compose.yml

数据库配置

默认配置了MariaDB数据库。如果把MariaDB配置去掉了,则会使用SQLite配置。

存储配置

volumes:
  # "/host/folder:/photoprism/folder"  # example
  - "~/Pictures:/photoprism/originals"

表示将宿主机上的/photoprism/originals目录,映射到容器内的~/Pictures目录下。

也可以使用多个存储位置,示例如下:

volumes:
  - "/home/username/Pictures:/photoprism/originals"
  - "/home/note/Pictures:/photoprism/originals/note"

下面三个位置,保存了全部的数据。

  • storage目录:配置文件
  • originals目录:原始图片
  • 数据库:

配置文件

/photoprism/storage中,默认会保存SQLite、config、cache、thumbnail和sidecar文件。

启动服务

docker compose up -d

watchtower可以自动更新正在运行的docker容器,是一个可选项。尝试时遇到点问题,先注释掉。

访问服务

http://local:2342

默认用户名:admin
默认密码:PHOTOPRISM_ADMIN_PASSWORD的值,默认为insecure

设置中文界面:Settings -> Language -> English 转为 简体中文。

照片导入

将照片导入宿主机目录中:/home/username/Pictures

更多用法见 [4]。

其它

  1. 进入容器中
docker compose exec photoprism bash
  1. 重新索引全部照片
docker compose exec photoprism photoprism index -f

其它命令:

ActionCommand
Start Servicesdocker compose up -d
Stop Servicesdocker compose stop
Download Updatesdocker compose pull
Uninstalldocker compose rm -s -v
View Logsdocker compose logs --tail=100 -f
Display Config Valuesdocker compose exec photoprism photoprism show config
Show Migration Statusdocker compose exec photoprism photoprism migrations ls
Repeat Failed Migrationsdocker compose exec photoprism photoprism migrations run -f
Reset Databasedocker compose exec photoprism photoprism reset -y
Backup Databasedocker compose exec photoprism photoprism backup -a -i
Restore Databasedocker compose exec photoprism photoprism restore -a -i
Change Admin Passworddocker compose exec photoprism photoprism passwd [username]
Show User Management Commandsdocker compose exec photoprism photoprism users help
Reset Usersdocker compose exec photoprism photoprism users reset -y
Show Face Recognition Commandsdocker compose exec photoprism photoprism faces help
Index Facesdocker compose exec photoprism photoprism faces index
Reset People & Facesdocker compose exec photoprism photoprism faces reset -f
Transcode Videos to AVCdocker compose exec photoprism photoprism convert
Regenerate Thumbnailsdocker compose exec photoprism photoprism thumbs -f
Update Indexdocker compose exec photoprism photoprism index --cleanup
Import Filesdocker compose exec photoprism photoprism import [path]

源码安装(跳过)

下载 photoprism 的最新release版本

wget https://github.com/photoprism/photoprism/archive/refs/tags/221118-e58fee0fb.zip

制作镜像

准备 docker-compose

sudo apt-get install docker-compose

制作镜像

docker compose pull
docker compose stop
docker compose up -d

结果

docker-compose pull
Pulling mariadb      ... done
Pulling traefik      ... done
Pulling keycloak     ... done
Pulling dummy-oidc   ... done
Pulling dummy-webdav ... done
Pulling photoprism   ... done
WARNING: Some service image(s) must be built from source by running:
    docker-compose build photoprism

其会下载依赖的mariadb,traefik,keycloak,dummy-oidc和dummy-webdav镜像。

$ docker-compose build photoprism
Building photoprism
…………
 => => naming to docker.io/photoprism/photoprism:develop                                                                                  0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

参考

  1. 支持人脸识别的相册PhotoPrism
  2. PhotoPrism: Browse Your Life in Pictures¶
  3. PhotoPrism Setup
  4. Docker Compose