Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan from scratch crashes #720

Closed
loulou91 opened this issue Jan 5, 2023 · 15 comments
Closed

Scan from scratch crashes #720

loulou91 opened this issue Jan 5, 2023 · 15 comments
Labels
bug Something isn't working

Comments

@loulou91
Copy link

loulou91 commented Jan 5, 2023

having so many (small) problems with my current ops base (53k pictures) I decided to restart the scan from scratch.
After about 1h40 the whole process was terminated. For "scan photos" task I saw item number increasing normally till 53k but some seconds after it came back to 0. Here is the final picture :
image
But 0 photo in Photo tab...
In ownphotos.log where are a lot errors as you can see here:

2023-01-05 17:57:46,861 : image_similarity.py : build_image_similarity_index : 90 : INFO : building similarity index took 0.02 seconds
2023-01-05 17:57:46,903 : image_similarity.py : build_image_similarity_index : 64 : INFO : building similarity index for user admin
2023-01-05 17:57:46,920 : image_similarity.py : build_image_similarity_index : 90 : INFO : building similarity index took 0.02 seconds
2023-01-05 17:57:46,958 : image_similarity.py : build_image_similarity_index : 64 : INFO : building similarity index for user admin
2023-01-05 17:57:46,975 : image_similarity.py : build_image_similarity_index : 90 : INFO : building similarity index took 0.02 seconds
2023-01-05 17:57:47,012 : image_similarity.py : build_image_similarity_index : 64 : INFO : building similarity index for user admin
2023-01-05 17:57:47,026 : image_similarity.py : build_image_similarity_index : 90 : INFO : building similarity index took 0.01 seconds
2023-01-05 17:58:29,673 : api_util.py : get_search_term_examples : 178 : INFO : 0 possible ids
2023-01-05 17:58:29,674 : api_util.py : get_search_term_examples : 191 : INFO : Getting search terms for user 1
2023-01-05 17:58:29,675 : api_util.py : get_search_term_examples : 192 : INFO : Found 0 photos
2023-01-05 17:58:36,490 : user.py : update : 259 : INFO : Updated scan directory for user /data
2023-01-05 17:58:43,361 : api_util.py : get_search_term_examples : 178 : INFO : 0 possible ids
2023-01-05 17:58:43,362 : api_util.py : get_search_term_examples : 191 : INFO : Getting search terms for user 1
2023-01-05 17:58:43,364 : api_util.py : get_search_term_examples : 192 : INFO : Found 0 photos
2023-01-05 17:59:07,053 : directory_watcher.py : handle_new_image : 78 : INFO : job 511d2003-77fb-4575-814b-315193970e0d: handling image /data/1963-2008 Videos Papy & Mamy/1962-08 vacances en Grèce.mp4
2023-01-05 17:59:07,123 : directory_watcher.py : handle_new_image : 78 : INFO : job 511d2003-77fb-4575-814b-315193970e0d: handling image /data/photos-m_et_jl_2006-2010/2006_03_25-Chambord/IMG_0051.JPG
2023-01-05 17:59:07,127 : directory_watcher.py : handle_new_image : 78 : INFO : job 511d2003-77fb-4575-814b-315193970e0d: handling image /data/photos-m_et_jl_2002-2005/2002_11_10_Anniv_Sophie_40/Photo_124.jpg
2023-01-05 17:59:07,187 : directory_watcher.py : handle_new_image : 200 : ERROR : job 511d2003-77fb-4575-814b-315193970e0d: could not load image /data/photos-m_et_jl_2002-2005/2002_11_10_Anniv_Sophie_40/Photo_124.jpg. reason: 'ManyRelatedManager' object has no attribute 'append'
Traceback (most recent call last):
  File "/code/api/directory_watcher.py", line 92, in handle_new_image
    photo.files.append(file)
AttributeError: 'ManyRelatedManager' object has no attribute 'append'
2023-01-05 17:59:07,198 : directory_watcher.py : handle_new_image : 200 : ERROR : job 511d2003-77fb-4575-814b-315193970e0d: could not load image /data/photos-m_et_jl_2006-2010/2006_03_25-Chambord/IMG_0051.JPG. reason: 'ManyRelatedManager' object has no attribute 'append'
Traceback (most recent call last):
  File "/code/api/directory_watcher.py", line 92, in handle_new_image
    photo.files.append(file)
AttributeError: 'ManyRelatedManager' object has no attribute 'append'

What do you think?

@loulou91 loulou91 added the bug Something isn't working label Jan 5, 2023
@loulou91
Copy link
Author

loulou91 commented Jan 6, 2023

In fact even with my ops base or test base, I'm no more able to scan an additional picture. I get the following error:
2023-01-06 07:19:24,693 : directory_watcher.py : handle_new_image : 200 : ERROR : job a831c860-c782-48e9-ba38-00a008be59f4: could not load image /data/...xxx.jpg. reason: 'ManyRelatedManager' object has no attribute 'append' Traceback (most recent call last): File "/code/api/directory_watcher.py", line 92, in handle_new_image photo.files.append(file) AttributeError: 'ManyRelatedManager' object has no attribute 'append'

@loulou91
Copy link
Author

loulou91 commented Jan 7, 2023

@sickelap @derneuere It looks as if today fix has solved the issue? isn't it?
But still an error ("TypeError: 'ManyRelatedManager' object is not iterable"):
2023-01-07 16:55:46,228 : directory_watcher.py : scan_photos : 375 : INFO : Scanned 3 files in : /data 2023-01-07 16:55:46,255 : directory_watcher.py : scan_photos : 377 : INFO : Finished updating album things 2023-01-07 16:55:46,263 : directory_watcher.py : scan_photos : 386 : ERROR : An error occurred: Traceback (most recent call last): File "/code/api/directory_watcher.py", line 382, in scan_photos existing_photo._check_files() File "/code/api/models/photo.py", line 668, in _check_files for file in self.files: TypeError: 'ManyRelatedManager' object is not iterable 2023-01-07 16:55:46,264 : directory_watcher.py : scan_photos : 390 : INFO : Added 3 photos 2023-01-07 16:55:46,429 : face_classify.py : train_faces : 243 : INFO : No labeled faces found

@sickelap
Copy link
Contributor

sickelap commented Jan 7, 2023

Did you run this on a fresh installation? If not, please let me know the details how this could be reproduced.

@loulou91
Copy link
Author

loulou91 commented Jan 7, 2023

very simple to reproduce for me.
pull and up from scratch, I mean librephotos directory containing only 1 directory picture containing 3 files in this test.

@sickelap
Copy link
Contributor

sickelap commented Jan 7, 2023

Recreated everything from scratch and it works fine. My guess is that you used an existing database. If so, could you please remove it and start over?

@loulou91
Copy link
Author

loulou91 commented Jan 7, 2023

I said : "up from scratch, I mean librephotos directory containing only 1 directory picture containing 3 files in this test."
Having an empty librephotos directory means for me that a new db will be created. I send you a MP.

@loulou91
Copy link
Author

I guess major error from myself was to still use too old docker-compose.yml and librephotos.env files! They were dated oct 21. I restarted from scratch with uptodate files and I went at the end of the process.
To be noted that scan process was about 1k photos per hour and that I had to restart the scan 3 times to go to the end (without clear warning in the "huge" logs)...
I close the issue.

@loulou91
Copy link
Author

loulou91 commented Jan 14, 2023

I reopen this subject... I started scan from scratch but with uptodate .yml and .env files in dev mode. Scan crashed with the following error. In addition I don't see any "Unknown - Other' cluster despite the fact that searching for "Unknown - Other" return many photos. I known that faces clustering was discussed here in oct / nov but I don't know clearly the final result and if the subject is supposed to be closed or not.
2023-01-14 11:39:17,686 : directory_watcher.py : handle_new_image : 164 : INFO : job 6d6a0c26-b7fc-46bb-b631-049a66454c6a: extract faces: /data/Spectacles persos/2021-06-30 Jean-Pierre.mp4, elapsed: 3.153509 2023-01-14 11:39:17,747 : directory_watcher.py : handle_new_image : 171 : INFO : job 6d6a0c26-b7fc-46bb-b631-049a66454c6a: image processed: /data/Spectacles persos/2021-06-30 Jean-Pierre.mp4, elapsed: 3.21446 2023-01-14 11:39:17,817 : directory_watcher.py : scan_photos : 375 : INFO : Scanned 4482 files in : /data 2023-01-14 11:39:26,380 : directory_watcher.py : scan_photos : 377 : INFO : Finished updating album things 2023-01-14 11:39:28,357 : directory_watcher.py : scan_photos : 386 : ERROR : An error occurred: Traceback (most recent call last): File "/code/api/directory_watcher.py", line 382, in scan_photos existing_photo._check_files() File "/code/api/models/photo.py", line 668, in _check_files for file in self.files: TypeError: 'ManyRelatedManager' object is not iterable 2023-01-14 11:39:28,360 : directory_watcher.py : scan_photos : 390 : INFO : Added 4341 photos 2023-01-14 11:39:55,530 : face_classify.py : train_faces : 251 : INFO : Before fitting 2023-01-14 11:40:11,020 : face_classify.py : train_faces : 255 : INFO : After fitting 2023-01-14 11:40:11,022 : face_classify.py : train_faces : 260 : INFO : Number of Cluster: 4752 2023-01-14 11:43:48,481 : api_util.py : get_search_term_examples : 178 : INFO : 100 possible ids 2023-01-14 11:43:48,483 : api_util.py : get_search_term_examples : 191 : INFO : Getting search terms for user 1 2023-01-14 11:43:48,576 : api_util.py : get_search_term_examples : 192 : INFO : Found 100 photos
image
image
image
image
image

@loulou91 loulou91 reopened this Jan 14, 2023
@loulou91
Copy link
Author

Don't know if it can help but here is the end of rqworker.log.
11:39:28 default: Job OK (fc7e9993-b126-4782-89c3-b9ce53759771) 11:39:28 Result is kept for 60 seconds 11:39:28 Cleaning registries for queue: default 11:39:28 default: api.face_classify.cluster_all_faces(<User: admin>, UUID('39cf8ed6-0313-4b34-834a-8428541de4c3')) (0aad336e-7160-4e58-8e79-20261f3c3030) [INFO] Deleting all clustered people [INFO] Deleting all clusters [INFO] Creating clusters 11:39:54 default: Job OK (0aad336e-7160-4e58-8e79-20261f3c3030) 11:39:54 Result is kept for 60 seconds 11:39:54 default: api.face_classify.train_faces(<User: admin>, UUID('17d95819-13c7-454f-93b0-c429b9100dd4')) (874a49ff-7b42-46f4-a977-24a4989e1fb7) 11:40:24 default: Job OK (874a49ff-7b42-46f4-a977-24a4989e1fb7) 11:40:24 Result is kept for 60 seconds 12:07:25 Cleaning registries for queue: default

@Nerodacles
Copy link

Don't know if it can help but here is the end of rqworker.log. 11:39:28 default: Job OK (fc7e9993-b126-4782-89c3-b9ce53759771) 11:39:28 Result is kept for 60 seconds 11:39:28 Cleaning registries for queue: default 11:39:28 default: api.face_classify.cluster_all_faces(<User: admin>, UUID('39cf8ed6-0313-4b34-834a-8428541de4c3')) (0aad336e-7160-4e58-8e79-20261f3c3030) [INFO] Deleting all clustered people [INFO] Deleting all clusters [INFO] Creating clusters 11:39:54 default: Job OK (0aad336e-7160-4e58-8e79-20261f3c3030) 11:39:54 Result is kept for 60 seconds 11:39:54 default: api.face_classify.train_faces(<User: admin>, UUID('17d95819-13c7-454f-93b0-c429b9100dd4')) (874a49ff-7b42-46f4-a977-24a4989e1fb7) 11:40:24 default: Job OK (874a49ff-7b42-46f4-a977-24a4989e1fb7) 11:40:24 Result is kept for 60 seconds 12:07:25 Cleaning registries for queue: default

All clusters are cleaned so that when facial recognition is done, it is more accurate, or so I think.

I reopen this subject... I started scan from scratch but with uptodate .yml and .env files in dev mode. Scan crashed with the following error. In addition I don't see any "Unknown - Other' cluster despite the fact that searching for "Unknown - Other" return many photos. I known that faces clustering was discussed here in oct / nov but I don't know clearly the final result and if the subject is supposed to be closed or not.

In my case it seems all fine!

image
image
image
image

The Unknown - Other faces appears in the labeled faces, not in interred and the search in all branches are erroring, see #686, im trying to setup the dev environment to try to resolve that!

@Nerodacles
Copy link

Oh and this is my docker.yml and the .env:

# DO NOT EDIT
# The .env file has everything you need to edit.
# Run options:
# 1. Use prebuilt images (preferred method):
#   run cmd: docker-compose up -d
# 2. Build images on your own machine:
#   build cmd: COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build
#   run cmd: docker-compose up -d

version: "3.7"
services:
  proxy:
    image: reallibrephotos/librephotos-proxy:${tag}
    container_name: lb_proxy
    restart: unless-stopped
    volumes:
      - ${myPhotos}:/data
      - ${data}/protected_media:/protected_media
    ports:
      - ${httpPort}:80
    networks:
      - proxy
      - default
    labels:
      - traefik.enable=true
      - traefik.http.routers.librephotos.entrypoints=https
      - traefik.http.routers.librephotos.rule=Host(`PRIVATE`)
      - traefik.http.routers.librephotos.tls=true
      - traefik.http.routers.librephotos.middlewares=defaultMiddlewares@file
      - traefik.http.routers.librephotos.service=librephotos
      - traefik.http.services.librephotos.loadbalancer.server.port=80
      - traefik.docker.network=proxy
    depends_on:
      - backend
      - frontend

  db:
    image: postgres:13
    container_name: lb_db
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${dbUser}
      - POSTGRES_PASSWORD=${dbPass}
      - POSTGRES_DB=${dbName}
    volumes:
      - ${data}/db:/var/lib/postgresql/data
    command: postgres -c fsync=off -c synchronous_commit=off -c full_page_writes=off -c random_page_cost=1.0
    healthcheck:
      test: psql -U ${dbUser} -d ${dbName} -c "SELECT 1;"
      interval: 5s
      timeout: 5s
      retries: 5

  frontend:
    image: reallibrephotos/librephotos-frontend:${tag}
    #image: reallibrephotos/librephotos-frontend:latest
    container_name: lb_frontend
    restart: unless-stopped
    depends_on:
      - backend

  backend:
    image: reallibrephotos/librephotos:${tag}
    container_name: lb_backend
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 4096M
        reservations:
          memory: 1024M
    volumes:
      - ${myPhotos}:/data
      - ${data}/protected_media:/protected_media
      - ${data}/logs:/logs
      - ${data}/cache:/root/.cache
    environment:
      - SECRET_KEY=${shhhhKey:-}
      - BACKEND_HOST=backend
      - ADMIN_EMAIL=${adminEmail:-}
      - ADMIN_USERNAME=${userName:-}
      - ADMIN_PASSWORD=${userPass:-}
      - DB_BACKEND=postgresql
      - DB_NAME=${dbName}
      - DB_USER=${dbUser}
      - DB_PASS=${dbPass}
      - DB_HOST=${dbHost}
      - DB_PORT=5432
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - MAPBOX_API_KEY="PRIVATE"
      - WEB_CONCURRENCY=${gunniWorkers:-1}
      - SKIP_PATTERNS=${skipPatterns:-}
      - ALLOW_UPLOAD=${allowUpload:-false}
      - DEBUG=0
      - HEAVYWEIGHT_PROCESS=${HEAVYWEIGHT_PROCESS:-3}
    depends_on:
      - db
      - redis
        
  redis:
    image: redis:6
    container_name: lb_redis
    restart: unless-stopped
    healthcheck:
      test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
      interval: 5s
      timeout: 5s
      retries: 12
 
networks:
  proxy:
    external: true
# This file contains all the things you need to change to set up your Libre Photos.
# There are a few items that must be set for it to work such as the location of your photos.
# After the mandatory entry's there are some optional ones that you may set.

# Start of mandatory changes.

# Location of your photos.
myPhotos=./librephotos/pictures

# Internal data of LibrePhotos
data=./librephotos/data

# ------------------------------------------------------------------------------------------------

# Wow, we are at the optional now. Pretty easy so far. You do not have to change any of the below.

#What port should Libre Photos be accessed at (Default 3000)
httpPort=3000

# What branch should we install the latest weekly build or the development branch (dev)
tag=dev

# Number of workers, which take care of the request to the api. This setting can dramatically affect the ram usage.
# A positive integer generally in the 2-4 x $(NUM_CORES) range.
# You’ll want to vary this a bit to find the best for your particular workload.
# Each worker needs 800MB of RAM. Change at your own will. Default is 2.
gunniWorkers=3

# You can set the database name. Did you know Libre Photos was forked from OwnPhotos?
dbName=PRIVATE

# Here you can change the user name for the database.
dbUser=PRIVATE

# The password used by the database.
dbPass=PRIVATE

# Database host. Only change this if you want to use your own existing Postgres server. If using your own server, you can remove the 'db' container from docker-compose.yml. If you're changing the name of the DB's container name (DB_CONT_NAME further down), you need to set this variable to match that name too.
dbHost=db

# Default minimum rating to interpret as favorited. This default value is used when creating a new user.
# Users can change this in their settings (Dashboards > Library).
DEFAULT_FAVORITE_MIN_RATING=4

# ---------------------------------------------------------------------------------------------

# If you are not a developer ignore the following parameters: you will never need them.

# Where shall we store the backend and frontend code files.
codedir=./librephotos/code

# Location for pgAdmin
pgAdminLocation=./librephotos/pgadmin

@loulou91
Copy link
Author

I use default values (ie without any modification) for docker-compose.yml (3.8) as well as for .env
_____________docker-compose.yml

DO NOT EDIT

The .env file has everything you need to edit.

Run options:

1. Use prebuilt images (preferred method):

run cmd: docker-compose up -d

2. Build images on your own machine:

build cmd: COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build

run cmd: docker-compose up -d

version: "3.8"
services:
proxy:
image: reallibrephotos/librephotos-proxy:${tag}
container_name: proxy
restart: unless-stopped
volumes:
- ${scanDirectory}:/data
- ${data}/protected_media:/protected_media
ports:
- ${httpPort}:80
depends_on:
- backend
- frontend

db:
image: postgres:13
container_name: db
restart: unless-stopped
environment:
- POSTGRES_USER=${dbUser}
- POSTGRES_PASSWORD=${dbPass}
- POSTGRES_DB=${dbName}
volumes:
- ${data}/db:/var/lib/postgresql/data
command: postgres -c fsync=off -c synchronous_commit=off -c full_page_writes=off -c random_page_cost=1.0
healthcheck:
test: psql -U ${dbUser} -d ${dbName} -c "SELECT 1;"
interval: 5s
timeout: 5s
retries: 5

frontend:
image: reallibrephotos/librephotos-frontend:${tag}
container_name: frontend
restart: unless-stopped

backend:
image: reallibrephotos/librephotos:${tag}
container_name: backend
restart: unless-stopped
volumes:
- ${scanDirectory}:/data
- ${data}/protected_media:/protected_media
- ${data}/logs:/logs
- ${data}/cache:/root/.cache
environment:
- SECRET_KEY=${shhhhKey:-}
- BACKEND_HOST=backend
- ADMIN_EMAIL=${adminEmail:-}
- ADMIN_USERNAME=${userName:-}
- ADMIN_PASSWORD=${userPass:-}
- DB_BACKEND=postgresql
- DB_NAME=${dbName}
- DB_USER=${dbUser}
- DB_PASS=${dbPass}
- DB_HOST=${dbHost}
- DB_PORT=5432
- REDIS_HOST=redis
- REDIS_PORT=6379
- MAPBOX_API_KEY=${mapApiKey:-}
- WEB_CONCURRENCY=${gunniWorkers:-1}
- SKIP_PATTERNS=${skipPatterns:-}
- ALLOW_UPLOAD=${allowUpload:-false}
- DEBUG=0
- HEAVYWEIGHT_PROCESS=${HEAVYWEIGHT_PROCESS:-}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy

redis:
image: redis:6
container_name: redis
restart: unless-stopped
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 5s
timeout: 5s
retries: 12
___________________________________________________________________. env _______________________

This file contains all the things you need to change to set up your Libre Photos.

There are a few items that must be set for it to work such as the location of your photos.

After the mandatory entries there are some optional ones that you may set.

Start of mandatory changes.

Location of your photos.

scanDirectory=./librephotos/pictures

Internal data of LibrePhotos

data=./librephotos/data

------------------------------------------------------------------------------------------------

Wow, we are at the optional now. Pretty easy so far. You do not have to change any of the below.

#What port should Libre Photos be accessed at (Default 3000)
httpPort=3000

What branch should we install the latest weekly build or the development branch (dev)

tag=dev

Number of workers, which take care of the request to the api. This setting can dramatically affect the ram usage.

A positive integer generally in the 2-4 x $(NUM_CORES) range.

You’ll want to vary this a bit to find the best for your particular workload.

Each worker needs 800MB of RAM. Change at your own will. Default is 2.

gunniWorkers=2

You can set the database name. Did you know Libre Photos was forked from OwnPhotos?

dbName=librephotos

Here you can change the user name for the database.

dbUser=docker

The password used by the database.

dbPass=AaAa1234

Default minimum rating to interpret as favorited. This default value is used when creating a new user.

Users can change this in their settings (Dashboards > Library).

DEFAULT_FAVORITE_MIN_RATING=4

Database host. Only change this if you want to use your own existing Postgres server. If using your own server, you can remove the 'db' container from docker-compose.yml. If you're changing the name of the DB's container name (DB_CONT_NAME further down), you need to set this variable to match that name too.

dbHost=db

Set the names of the docker containers to your own entries. Or don't, I'm not your dad.

Changing these will require you to make rename to rename the services, and start the system with your chosen docker-compose up -d invocation again.

Note that changing the DB_CONT_NAME will also need you to set the dbHost variable to the same value.

DB_CONT_NAME=db
BACKEND_CONT_NAME=backend
FRONTEND_CONT_NAME=frontend
PROXY_CONT_NAME=proxy
REDIS_CONT_NAME=redis
PGADMIN_CONT_NAME=pgadmin

---------------------------------------------------------------------------------------------

If you are not a developer ignore the following parameters: you will never need them.

Where shall we store the backend and frontend code files.

codedir=./librephotos/code

Location for pgAdmin

pgAdminLocation=./librephotos/pgadmin

@loulou91
Copy link
Author

You say "The Unknown - Other faces appears in the labeled faces" I understand that you have a cluster of 1163 faces in labelled tab in your case? In my case I have none...

@loulou91
Copy link
Author

I noted several inconsistencies in captures provided by Nerodacles which go in the same direction than me!
1/ you have 146 people on face tab but 144 Library tab
2/ you have 32674 faces on face tab (24122+311+8152+89) but 33683 or 34618 (24122+9333+1163) on Library tab
I made a lot of tests and I'm pretty sure many unknown other faces are lost somewhere. But I see them doing a search with "Unknown - Other" keyword and looking at picture details!

image image image image

@loulou91
Copy link
Author

To clear this issue report which mixes several things, I think i'm going to close and to open at least 2 new.

@derneuere derneuere changed the title Scan from scrtach crashes Scan from scratch crashes Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants