@@ -94,62 +94,54 @@ public function classify(array $queueFiles): void {
9494 $ filteredQueueFiles [] = $ queueFile ;
9595 }
9696
97- $ usersToCluster = [];
98- try {
99- $ classifierProcess = $ this ->classifyFiles (self ::MODEL_NAME , $ filteredQueueFiles , $ timeout );
97+ $ classifierProcess = $ this ->classifyFiles (self ::MODEL_NAME , $ filteredQueueFiles , $ timeout );
10098
101- /**
102- * @var list<array> $faces
103- */
104- foreach ($ classifierProcess as $ queueFile => $ faces ) {
105- $ this ->logger ->debug ('Face results for ' . $ queueFile ->getFileId () . ' are in ' );
106- foreach ($ faces as $ face ) {
107- if ($ face ['score ' ] < self ::MIN_FACE_RECOGNITION_SCORE ) {
108- $ this ->logger ->debug ('Face score too low. continuing with next face. ' );
109- continue ;
110- }
111- if (abs ($ face ['angle ' ]['roll ' ]) > self ::MAX_FACE_ROLL || abs ($ face ['angle ' ]['yaw ' ]) > self ::MAX_FACE_YAW ) {
112- $ this ->logger ->debug ('Face is not straight. continuing with next face. ' );
113- continue ;
114- }
99+ /**
100+ * @var list<array> $faces
101+ */
102+ foreach ($ classifierProcess as $ queueFile => $ faces ) {
103+ $ this ->logger ->debug ('Face results for ' . $ queueFile ->getFileId () . ' are in ' );
104+ foreach ($ faces as $ face ) {
105+ if ($ face ['score ' ] < self ::MIN_FACE_RECOGNITION_SCORE ) {
106+ $ this ->logger ->debug ('Face score too low. continuing with next face. ' );
107+ continue ;
108+ }
109+ if (abs ($ face ['angle ' ]['roll ' ]) > self ::MAX_FACE_ROLL || abs ($ face ['angle ' ]['yaw ' ]) > self ::MAX_FACE_YAW ) {
110+ $ this ->logger ->debug ('Face is not straight. continuing with next face. ' );
111+ continue ;
112+ }
115113
116- try {
117- $ node = $ this ->rootFolder ->getFirstNodeById ($ queueFile ->getFileId ());
118- $ userIds = $ node !== null ? $ this ->getUsersWithFileAccess ($ node ) : [];
119- } catch (InvalidPathException |NotFoundException $ e ) {
120- $ userIds = [];
121- }
114+ try {
115+ $ node = $ this ->rootFolder ->getFirstNodeById ($ queueFile ->getFileId ());
116+ $ userIds = $ node !== null ? $ this ->getUsersWithFileAccess ($ node ) : [];
117+ } catch (InvalidPathException |NotFoundException $ e ) {
118+ $ userIds = [];
119+ }
122120
123- // Insert face detection for all users with access
124- foreach ($ userIds as $ userId ) {
125- $ this ->logger ->debug ('preparing face detection for user ' . $ userId );
126- $ faceDetection = new FaceDetection ();
127- $ faceDetection ->setX ($ face ['x ' ]);
128- $ faceDetection ->setY ($ face ['y ' ]);
129- $ faceDetection ->setWidth ($ face ['width ' ]);
130- $ faceDetection ->setHeight ($ face ['height ' ]);
131- $ faceDetection ->setVector ($ face ['vector ' ]);
132- $ faceDetection ->setFileId ($ queueFile ->getFileId ());
133- $ faceDetection ->setUserId ($ userId );
134- try {
135- $ this ->faceDetections ->insert ($ faceDetection );
136- } catch (Exception $ e ) {
137- $ this ->logger ->error ('Could not store face detection in database ' , ['exception ' => $ e ]);
138- continue ;
139- }
140- $ usersToCluster [$ userId ] = true ;
121+ // Insert face detection for all users with access
122+ foreach ($ userIds as $ userId ) {
123+ $ this ->logger ->debug ('preparing face detection for user ' . $ userId );
124+ $ faceDetection = new FaceDetection ();
125+ $ faceDetection ->setX ($ face ['x ' ]);
126+ $ faceDetection ->setY ($ face ['y ' ]);
127+ $ faceDetection ->setWidth ($ face ['width ' ]);
128+ $ faceDetection ->setHeight ($ face ['height ' ]);
129+ $ faceDetection ->setVector ($ face ['vector ' ]);
130+ $ faceDetection ->setFileId ($ queueFile ->getFileId ());
131+ $ faceDetection ->setUserId ($ userId );
132+ try {
133+ $ this ->faceDetections ->insert ($ faceDetection );
134+ } catch (\Throwable $ e ) {
135+ $ this ->logger ->error ('Could not store face detection in database ' , ['exception ' => $ e ]);
136+ continue ;
141137 }
142- $ this ->config -> setAppValueString ( self :: MODEL_NAME . ' .status ' , ' true ' );
143- $ this ->config -> setAppValueString ( self :: MODEL_NAME . ' .lastFile ' , ( string ) time () );
138+ $ this ->logger -> debug ( ' scheduling ClusterFacesJob for user ' . $ userId );
139+ $ this ->jobList -> add (ClusterFacesJob::class, [ ' userId ' => $ userId ] );
144140 }
141+ $ this ->config ->setAppValueString (self ::MODEL_NAME . '.status ' , 'true ' );
142+ $ this ->config ->setAppValueString (self ::MODEL_NAME . '.lastFile ' , (string )time ());
145143 }
146- } finally {
147- $ usersToCluster = array_keys ($ usersToCluster );
148- foreach ($ usersToCluster as $ userId ) {
149- $ this ->logger ->debug ('scheduling ClusterFacesJob for user ' . $ userId );
150- $ this ->jobList ->add (ClusterFacesJob::class, ['userId ' => $ userId ]);
151- }
152- $ this ->logger ->debug ('face classifier end ' );
153144 }
145+ $ this ->logger ->debug ('face classifier end ' );
154146 }
155147}
0 commit comments