Add "forget" as face type

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2023-01-28 18:56:32 -08:00
parent 34960de283
commit f6685e78e1
5 changed files with 32 additions and 18 deletions

View File

@ -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 = () => {
<Button onClick={guessIdentity}>Guess</Button>
</>}
{ selected.length !== 0 && <>
<Button onClick={forgetFace}>Forget</Button>
<Button onClick={removeFaceFromIdentity}>Remove</Button>
<Button onClick={updateFasAsNotFace}>Not a face</Button>
<Button onClick={changeSelectedIdentity}>Change Identity</Button>

View File

@ -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():

View File

@ -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',
},

View File

@ -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" });

View File

@ -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, {