DivisionByZeroError: CreateClustersTask.php:168
Opened this issue · 2 comments
I started getting this error when I run face:background_job. It wasn't occurring before. I didn't change any configuration.
Make sure you read all the documentation, and the FAQ, and that the issue has not been reported before. 😉
Expected behaviour
- Execute a background_job successfully
Actual behaviour
- Throwing an unhandled exception
Steps to reproduce
- Run
php occ face:background_job
Server configuration
- Dockerized setup:
-
Operating system:
-
Ubuntu server:
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy
-
Docker version 20.10.18, build b40c2f6
-
Pdlib version: 1.0.2
-
How is DLib installed: Installed correctly, as the
background_job
command was working -
How is PDlib installed: Make sure it is working correctly with this tool
-
PHP version: PHP 8.2.19
-
Web server: apache
-
Database:: postgres:9.6.22
-
Nextcloud version: 29.0.0
Client configuration
-
Browser: Chrome
-
Operating system:
Logs
$ php occ face:background_job
1/8 - Executing task CheckRequirementsTask (Check all requirements)
2/8 - Executing task CheckCronTask (Check that service is started from either cron or from command)
3/8 - Executing task DisabledUserRemovalTask (Purge all the information of a user when disable the analysis.)
4/8 - Executing task StaleImagesRemovalTask (Crawl for stale images (either missing in filesystem or under .nomedia) and remove them from DB)
5/8 - Executing task CreateClustersTask (Create new persons or update existing persons)
Skipping cluster creation, not enough data (yet) collected. For cluster creation, you need either one of the following:
* have 1000 faces already processed
* or you need to have 95% of you images processed
Use stats command to track progress
Clusters already exist, estimated there is no need to recreate them
Face clustering will be created for the first time.
There are 0 faces for clustering
An unhandled exception has been thrown:
DivisionByZeroError: Division by zero in /var/www/html/custom_apps/facerecognition/lib/BackgroundJob/Tasks/CreateClustersTask.php:168
Stack trace:
#0 /var/www/html/custom_apps/facerecognition/lib/BackgroundJob/Tasks/CreateClustersTask.php(90): OCA\FaceRecognition\BackgroundJob\Tasks\CreateClustersTask->createClusterIfNeeded('admin')
#1 /var/www/html/custom_apps/facerecognition/lib/BackgroundJob/BackgroundService.php(150): OCA\FaceRecognition\BackgroundJob\Tasks\CreateClustersTask->execute(Object(OCA\FaceRecognition\BackgroundJob\FaceRecognitionContext))
#2 /var/www/html/custom_apps/facerecognition/lib/Command/BackgroundCommand.php(192): OCA\FaceRecognition\BackgroundJob\BackgroundService->execute(0, false, NULL, NULL, 'default-mode')
#3 /var/www/html/3rdparty/symfony/console/Command/Command.php(298): OCA\FaceRecognition\Command\BackgroundCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/html/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OCA\FaceRecognition\Command\BackgroundCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/console.php(113): OC\Console\Application->run()
#9 /var/www/html/occ(11): require_once('/var/www/html/c...')
Background task log with debug.
sudo -u apache php occ -vvv face:background_job
Insert your background log here
Web server error log
Web server error log
Insert your webserver log here
Nextcloud log (data/nextcloud.log)
Nextcloud log
Insert your Nextcloud log here
Browser log
Browser log
Insert your browser log here, this could for example include:
a) The javascript console log
b) The network log
c) ...
It looks like it has evaluated your pictures but detected no faces in any of them and hit an unhandled exception. I assume this error goes away if the user has any pictures with detectable faces in it, but you'll probably need to pass --defer-clustering
to the background task so that it will attempt the face detection first before hitting this divide by zero and breaking during clustering before it otherwise would get to the detection.
Still seems like a bug that needs fixing because one user having this condition might break things for other users since the script bails at that point.
D'Oh!. I didn't consider it... I'll fix it tomorrow, but as vwbusguy says, you can use the --defer-clustering option.