diff --git a/BUGs b/BUGs index 6b9c263..80248bf 100644 --- a/BUGs +++ b/BUGs @@ -1,6 +1,6 @@ ### Next: 15 BUG-11: Ai ref img jobs are not able to be "re-run" - - only need to calc refimgs once (so timestamp in refimg and check it) + DONE - only need to calc refimgs once (so timestamp in refimg and check it) - if we re-run a process AI job and no file changes, then don't process (as above) - if we do see a new file/updated file, should delete all FPLs then insert new -- probably should insert new into a file.people.append(...), rather than FPL direct diff --git a/TODO b/TODO index 21aa9c6..ce1384c 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ ## DB - NEW_FILE -> add, has_unidentified_face + should FPL really be EPL? + + FILE -> add, has_unidentified_face ?has_face?, AI_SCAN: diff --git a/pa_job_manager.py b/pa_job_manager.py index 27c9e09..34f8b36 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -147,9 +147,10 @@ class Refimg(Base): id = Column(Integer, Sequence('refimg_id_seq'), primary_key=True ) fname = Column(String(256), unique=True, nullable=False) encodings = Column(LargeBinary) + created_on = Column(Float) def __repr__(self): - return "".format(self.id, self.fname, self.encodings ) + return f"" class File_Person_Link(Base): __tablename__ = "file_person_link" @@ -545,10 +546,16 @@ def generateUnknownEncodings(im): def generateKnownEncodings(person): for refimg in person.refimg: - img = face_recognition.load_image_file('reference_images/'+refimg.fname) + file = 'reference_images/'+refimg.fname + stat = os.stat(file) + if refimg.created_on and stat.st_ctime < refimg.created_on: + print("DEBUG: skipping re-creating encoding for refimg because file has changed since we did this before") + continue + img = face_recognition.load_image_file(file) location = face_recognition.face_locations(img) encodings = face_recognition.face_encodings(img, known_face_locations=location) refimg.encodings = encodings[0].tobytes() + refimg.created_on = time.time() session.add(refimg) session.commit() diff --git a/tables.sql b/tables.sql index ad17e7f..da88025 100644 --- a/tables.sql +++ b/tables.sql @@ -25,6 +25,7 @@ create table PERSON ( ID integer, TAG varchar(48), FIRSTNAME varchar(48), SURNAM constraint PK_PERSON_ID primary key(ID) ); create table REFIMG ( ID integer, FNAME varchar(256), ENCODINGS bytea, + CREATED_ON fLOAT, constraint PK_REFIMG_ID primary key(ID) ); create table FILE_PERSON_LINK ( FILE_ID integer, PERSON_ID integer,