Skip to content

Commit

Permalink
enh(ClusterFaces): Add batch-size option
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Mar 19, 2023
1 parent 308f9d4 commit 622ff91
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Command/ClusterFaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCP\DB\Exception;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class ClusterFaces extends Command {
Expand All @@ -35,7 +36,8 @@ public function __construct(Logger $logger, FaceDetectionMapper $detectionMapper
*/
protected function configure() {
$this->setName('recognize:cluster-faces')
->setDescription('Cluster detected faces per user');
->setDescription('Cluster detected faces per user (Memory usage will grow with O(n²): n=2000: 450MB, n=4000: 700MB, n=5000: 1200MB)')
->addOption('batch-size', 'b', InputOption::VALUE_REQUIRED, 'The number of face detections to cluster in one go. 0 for no limit.', 0);
}

/**
Expand All @@ -59,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($userIds as $userId) {
$this->logger->info('Clustering face detections for user ' . $userId);
try {
$this->clusterAnalyzer->calculateClusters($userId);
$this->clusterAnalyzer->calculateClusters($userId, $input->getOption('batch-size'));
} catch (\JsonException|Exception $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
}
Expand Down

0 comments on commit 622ff91

Please sign in to comment.