now have functional add/remove manual override to existing person

This commit is contained in:
2022-06-11 22:41:31 +10:00
parent 8c78d9e633
commit a53d4896b0
6 changed files with 175 additions and 84 deletions

52
face.py
View File

@@ -1,6 +1,7 @@
from main import db, app, ma
from sqlalchemy import Sequence
from sqlalchemy.exc import SQLAlchemyError
from shared import PA
# DEL ME SOON
@@ -64,24 +65,33 @@ class FaceRefimgLink(db.Model):
return f"<face_id: {self.face_id}, refimg_id={self.refimg_id}, face_distance: {self.face_distance}"
### DDP: todo next, make these into sqlachemy classes, THEN person.py add the override in ORM, THEN draw override in blue/not green in DrawImg
### THEN find_person needs to call appropriate override func (OR pass in type?) and get it to be smarter - that sounds okay actually
# create table FACE_OVERRIDE_TYPE ( ID integer, NAME varchar unique, constraint PK_FACE_OVERRIDE_TYPE_ID primary key(ID) );
#create sequence FACE_OVERRIDE_TYPE_ID_SEQ;
#create sequence FACE_OVERRIDE_ID_SEQ;
#create table FACE_OVERRIDE_TYPE ( ID integer, NAME varchar unique, constraint PK_FACE_OVERRIDE_TYPE_ID primary key(ID) );
#insert into FACE_OVERRIDE_TYPE values ( (select nextval('FACE_OVERRIDE_TYPE_ID_SEQ')), 'Not a face' );
#insert into FACE_OVERRIDE_TYPE values ( (select nextval('FACE_OVERRIDE_TYPE_ID_SEQ')), 'Too young' );
#insert into FACE_OVERRIDE_TYPE values ( (select nextval('FACE_OVERRIDE_TYPE_ID_SEQ')), 'Ignore face' );
#insert into FACE_OVERRIDE_TYPE values ( (select nextval('FACE_OVERRIDE_TYPE_ID_SEQ')), 'Manual match' );
#
#-- keep non-redundant FACE because, when we rebuild data we may have a null FACE_ID, but still want to connect to this override
#-- from a previous AI pass... (would happen if we delete a file and then reimport/scan it), OR, more likely we change (say) a threshold, etc.
#-- any reordering of faces, generates new face_ids... (but if the face data was the same, then this override should stand)
#create table FACE_NO_MATCH_OVERRIDE ( ID integer, FACE_ID integer, TYPE integer, FACE bytea,
# constraint FK_FNMO_FACE_ID foreign key (FACE_ID) references FACE(ID),
# constraint FK_FNMO_TYPE foreign key (TYPE) references FACE_OVERRIDE_TYPE(ID),
# constraint PK_FNMO_ID primary key(ID) );
#
#-- manual match goes to person not refimg, so on search, etc. we deal with this anomaly (via sql not ORM)
#create table FACE_MANUAL_OVERRIDE ( ID integer, FACE_ID integer, PERSON_ID integer, TYPE integer, constraint PK_FACE_MANUAL_OVERRIDE_ID primary key(ID) );
class FaceOverrideType(db.Model):
__tablename__ = "face_override_type"
id = db.Column(db.Integer, db.Sequence('face_override_type_id_seq'), primary_key=True )
name = db.Column( db.String )
def __repr__(self):
return f"<id: {self.id}, name={self.name}>"
class FaceNoMatchOverride(db.Model):
__tablename__ = "face_no_match_override"
id = db.Column(db.Integer, db.Sequence('face_override_id_seq'), primary_key=True )
face_id = db.Column(db.Integer, db.ForeignKey("face.id"), primary_key=True )
type_id = db.Column(db.Integer, db.ForeignKey("face_override_type.id"))
type = db.relationship("FaceOverrideType")
face = db.Column( db.LargeBinary )
def __repr__(self):
return f"<id: {self.id}, face_id={self.face_id}, type: {self.type}>"
class FaceManualOverride(db.Model):
__tablename__ = "face_manual_override"
id = db.Column(db.Integer, db.Sequence('face_override_id_seq'), primary_key=True )
face_id = db.Column(db.Integer, db.ForeignKey("face.id"), primary_key=True )
face = db.Column( db.LargeBinary )
person_id = db.Column(db.Integer, db.ForeignKey("person.id"), primary_key=True )
person = db.relationship("Person")
def __repr__(self):
return f"<id: {self.id}, face_id={self.face_id}, person_id={self.person_id}>"