diff --git a/client/src/App.tsx b/client/src/App.tsx index 81439df..7e4d0a3 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -738,6 +738,26 @@ const App = () => { } }; + const forgetFace = async () => { + try { + const res = await window.fetch( + `${base}/api/v1/faces`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + action: 'forget', + faces: selected + }) + }); + await res.json(); + removeFacesFromIdentity(selected); + deselectAll(); + } catch (error) { + console.error(error); + } + }; + + const changeSelectedIdentity = async () => { if (selectedIdentities.length === 0) { window.alert('You need to select an identity first (CTRL+CLICK)'); @@ -928,6 +948,7 @@ const App = () => { } { selected.length !== 0 && <> + diff --git a/ketrface/ketrface/db.py b/ketrface/ketrface/db.py index f247a07..6f65af7 100644 --- a/ketrface/ketrface/db.py +++ b/ketrface/ketrface/db.py @@ -101,6 +101,7 @@ def load_faces(db_path ): JOIN facedescriptors ON (faces.descriptorId=facedescriptors.id) WHERE faces.identityId IS null AND faces.classifiedBy != 'not-a-face' + AND faces.classifiedBy != 'forget' AND faces.photoId=photos.id ''') for row in res.fetchall(): diff --git a/server/db/photos.js b/server/db/photos.js index 0658612..1ec5dc2 100755 --- a/server/db/photos.js +++ b/server/db/photos.js @@ -197,6 +197,7 @@ function init() { type: Sequelize.DataTypes.ENUM( 'machine', /* DBSCAN with VGG-Face */ 'human', /* Human identified */ + 'forget', /* implies "human"; identityId=NULL */ 'not-a-face'), /* implies "human"; identityId=NULL */ defaultValue: 'machine', }, diff --git a/server/routes/faces.js b/server/routes/faces.js index 41ccce8..8c20b4e 100755 --- a/server/routes/faces.js +++ b/server/routes/faces.js @@ -36,27 +36,16 @@ router.put("/:id?", async (req, res/*, next*/) => { } const { action } = req.body; console.log(`${action}: ${faces}`); - switch (action) { - case 'not-a-face': + if ([ 'not-a-face', 'forget' ].indexOf(action) !== -1) { await photoDB.sequelize.query( - `UPDATE faces SET classifiedBy='not-a-face',identityId=NULL ` + + `UPDATE faces SET classifiedBy=':action',identityId=NULL ` + `WHERE id IN (:faces)`, { - replacements: { faces } + replacements: { + action, + faces + } } ); - /* - faces = await photoDB.sequelize.query( - 'SELECT * FROM faces WHERE id IN (:faces)', { - replacements: { faces }, - type: photoDB.Sequelize.QueryTypes.SELECT, - raw: true - } - ); - faces.forEach(face => { - face.faceId = face.id; - delete face.id; - }); - */ return res.status(200).json(faces); } return res.status(400).json({ message: "Invalid request" }); diff --git a/server/routes/identities.js b/server/routes/identities.js index a9c6088..751596f 100755 --- a/server/routes/identities.js +++ b/server/routes/identities.js @@ -528,10 +528,12 @@ const getUnknownIdentity = async (faceCount) => { faces AS total WHERE total.identityId IS NULL - AND total.classifiedBy != 'not-a-face') AS total + AND total.classifiedBy != 'not-a-face' + AND total.classifiedBy != 'forget') AS total WHERE faces.identityId IS NULL AND faces.classifiedBy != 'not-a-face' + AND total.classifiedBy != 'forget' ${ limit }`; unknownIdentity.relatedFaces = await photoDB.sequelize.query(sql, {