Skip to content

Commit

Permalink
Merge pull request #778 from matiasdelellis/nc30
Browse files Browse the repository at this point in the history
Add support for NC30 and deprecate NC28
  • Loading branch information
matiasdelellis authored Nov 11, 2024
2 parents cbf6ad8 + 6fc4ad4 commit 37641e7
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.1']
php-versions: ['8.2']
databases: ['mysql']
server-versions: ['stable28']
server-versions: ['stable29']

name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3']
php-versions: ['8.1', '8.2', '8.3']
databases: ['sqlite', 'mysql', 'pgsql']
server-versions: ['stable28', 'stable29']
server-versions: ['stable29', 'stable30']

name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ocp-version: ['dev-stable28']
ocp-version: ['dev-stable29']
name: Nextcloud ${{ matrix.ocp-version }}
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- **🚀 Build your own thing:** FaceRecognition app is just a basic building block. Through FaceRecognition API, you can build your advanced scenarios - automatically add tags to images, connect contacts and persons, share images from specific person… We want to hear your ideas!
]]>
</description>
<version>0.9.51</version>
<version>0.9.60</version>
<licence>agpl</licence>
<author>Matias De lellis</author>
<author>Branko Kokanovic</author>
Expand All @@ -34,7 +34,7 @@
<screenshot>https://matiasdelellis.github.io/img/facerecognition/facerecognition-assign-initial-name.jpeg</screenshot>
<dependencies>
<php min-version="8.0" max-version="8.3" />
<nextcloud min-version="28" max-version="29"/>
<nextcloud min-version="29" max-version="30"/>
</dependencies>
<repair-steps>
<uninstall>
Expand Down
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 = $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
2 changes: 2 additions & 0 deletions lib/Db/Face.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public function __construct() {
$this->addType('image', 'integer');
$this->addType('person', 'integer');
$this->addType('isGroupable', 'bool');
$this->addType('descriptor', 'json');
$this->addType('creationTime', 'datetime');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ const FrDialogs = {
var defer = $.Deferred();
if (!this.$messageTemplate) {
var self = this;
$.get(OC.filePath('core', 'templates', 'message.html'), function (tmpl) {
$.get(OC.filePath('facerecognition', 'templates', 'message.html'), function (tmpl) {
self.$messageTemplate = $(tmpl);
defer.resolve(self.$messageTemplate);
})
Expand Down
16 changes: 6 additions & 10 deletions src/personal.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ View.prototype = {
});

$('#show-more-clusters').click(function () {
let button = $(this);
button.css("cursor", "wait");
self._persons.loadUnassignedClusters().done(function () {
button.css("cursor", "");
if (self._persons.getUnassignedClusters().length > 0) {
self.renameUnassignedClusterDialog();
} else {
Expand All @@ -421,7 +424,10 @@ View.prototype = {
});

$('#show-ignored-clusters').click(function () {
let button = $(this);
button.css("cursor", "wait");
self._persons.loadIgnoredClusters().done(function () {
button.css("cursor", "");
if (self._persons.getIgnoredClusters().length > 0) {
self.renameIgnoredClusterDialog();
} else {
Expand Down Expand Up @@ -541,16 +547,6 @@ View.prototype = {
});
});

$('#facerecognition #show-ignored-clusters').click(function () {
$(this).css("cursor", "wait");
var person = self._persons.getActivePerson();
self._persons.loadClustersByName(person.name).done(function () {
self.renderContent();
}).fail(function () {
OC.Notification.showTemporary(t('facerecognition', 'There was an error when trying to find photos of your friend'));
});
});

$('#facerecognition .icon-back').click(function () {
self._persons.unsetActive();
self.renderContent();
Expand Down
3 changes: 3 additions & 0 deletions templates/message.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="{dialog_name}" title="{title} ">
<p><span class="ui-icon ui-icon-{type}"></span>{message}</p>
</div>
9 changes: 9 additions & 0 deletions tests/Integration/CreateClustersTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public function testCreateSingleFaceCluster() {
$face = Face::fromModel($image->getId(), array("left"=>0, "right"=>100, "top"=>0, "bottom"=>100, "detection_confidence"=>1.0));
$faceMapper->insertFace($face);

/* Check inserted face */
$min_face_size = $settingsService->getMinimumFaceSize();
$min_confidence = $settingsService->getMinimumConfidence();

$groupablefaces = count($faceMapper->getGroupableFaces($this->user->getUID(), ModelManager::DEFAULT_FACE_MODEL_ID, $min_face_size, $min_confidence));
$this->assertEquals(1, $groupablefaces);
$nonGroupablefaces = count($faceMapper->getNonGroupableFaces($this->user->getUID(), ModelManager::DEFAULT_FACE_MODEL_ID, $min_face_size, $min_confidence));
$this->assertEquals(0, $nonGroupablefaces);

// With a single face should never create clusters.
$this->doCreateClustersTask($personMapper, $imageMapper, $faceMapper, $settingsService, $this->user);

Expand Down

0 comments on commit 37641e7

Please sign in to comment.