Skip to content

Commit

Permalink
Fix face clustering when dont set batches and improve comments.
Browse files Browse the repository at this point in the history
This was broken in commit "A bit more aggressively.." and just discovered
it through automated tests.
  • Loading branch information
matiasdelellis committed Oct 29, 2024
1 parent 143f59e commit 87baf48
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/BackgroundJob/Tasks/CreateClustersTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,20 @@ private function createClusterIfNeeded(string $userId) {
$facesCount = count($faces);
$this->logInfo('There are ' . $facesCount . ' faces for clustering.');

$noSlices = 0;
// The default slice is just one for the total.
$noSlices = 1;
$sliceSize = $facesCount;

$defaultSlice = $this->settingsService->getClusterigBatchSize();
if ($facesCount > 0 && $defaultSlice > 0) {
// The minimum batch size is 20000 faces
$defaultSlice = max($defaultSlice, 2000);
// Now calculate it if there is a batch size configured.
$batchSize = -1;//$this->settingsService->getClusterigBatchSize();
if ($facesCount > 0 && $batchSize > 0) {
// The minimum batch size is 2000 faces.
$batchSize = max($batchSize, 2000);
// The maximun batch size is the faces count.
$defaultSlice = min($defaultSlice, $facesCount);
$noSlices = intval($facesCount / $defaultSlice) + 1;
$batchSize = min($batchSize, $facesCount);

// Calculate the number of slices and their sizes.
$noSlices = intval($facesCount / $batchSize) + 1;
$sliceSize = ceil($facesCount / $noSlices);
}

Expand Down

0 comments on commit 87baf48

Please sign in to comment.