1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2020, Matias De lellis <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Matias De lellis <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @license GNU AGPL version 3 or any later version |
8
|
|
|
* |
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
12
|
|
|
* License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace OCA\FaceRecognition\Model; |
25
|
|
|
|
26
|
|
|
use OCP\IConfig; |
27
|
|
|
use OCP\Files\IAppData; |
28
|
|
|
use OCP\Files\IRootFolder; |
29
|
|
|
use OCP\Files\NotFoundException; |
30
|
|
|
|
31
|
|
|
use OCA\FaceRecognition\Model\DlibCnnModel; |
32
|
|
|
|
33
|
|
|
use OCA\FaceRecognition\Model\DlibCnn68Model; |
34
|
|
|
use OCA\FaceRecognition\Model\DlibCnn5Model; |
35
|
|
|
|
36
|
|
|
class ModelManager { |
37
|
|
|
|
38
|
|
|
/** @var DlibCnn5Model */ |
39
|
|
|
private $dlibCnn5Model; |
40
|
|
|
|
41
|
|
|
/** @var DlibCnn68Model */ |
42
|
|
|
private $dlibCnn68Model; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param DlibCnn5Model $model |
46
|
|
|
* @param DlibCnn68Model $model |
47
|
|
|
*/ |
48
|
1 |
|
public function __construct(DlibCnn5Model $dlibCnn5Model, |
49
|
|
|
DlibCnn68Model $dlibCnn68Model) |
50
|
|
|
{ |
51
|
1 |
|
$this->dlibCnn5Model = $dlibCnn5Model; |
52
|
1 |
|
$this->dlibCnn68Model = $dlibCnn68Model; |
53
|
1 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param int $version model version |
57
|
|
|
* @return DlibCnnModel|null |
58
|
|
|
*/ |
59
|
4 |
|
public function getModel(int $version): ?DlibCnnModel { |
60
|
|
|
switch ($version) { |
61
|
4 |
|
case 1: |
62
|
4 |
|
$model = $this->dlibCnn5Model; |
63
|
4 |
|
break; |
64
|
|
|
case 2: |
65
|
|
|
$model = $this->dlibCnn68Model; |
66
|
|
|
break; |
67
|
|
|
default: |
68
|
|
|
$model = null; |
69
|
|
|
break; |
70
|
|
|
} |
71
|
4 |
|
return $model; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |