partial fix/optimisation for refimgs, only recalc if file is newer than when we build the refimg encoding
This commit is contained in:
2
BUGs
2
BUGs
@@ -1,6 +1,6 @@
|
|||||||
### Next: 15
|
### Next: 15
|
||||||
BUG-11: Ai ref img jobs are not able to be "re-run"
|
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 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
|
- 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
|
-- probably should insert new into a file.people.append(...), rather than FPL direct
|
||||||
|
|||||||
4
TODO
4
TODO
@@ -1,5 +1,7 @@
|
|||||||
## DB
|
## DB
|
||||||
NEW_FILE -> add, has_unidentified_face
|
should FPL really be EPL?
|
||||||
|
|
||||||
|
FILE -> add, has_unidentified_face
|
||||||
?has_face?,
|
?has_face?,
|
||||||
|
|
||||||
AI_SCAN:
|
AI_SCAN:
|
||||||
|
|||||||
@@ -147,9 +147,10 @@ class Refimg(Base):
|
|||||||
id = Column(Integer, Sequence('refimg_id_seq'), primary_key=True )
|
id = Column(Integer, Sequence('refimg_id_seq'), primary_key=True )
|
||||||
fname = Column(String(256), unique=True, nullable=False)
|
fname = Column(String(256), unique=True, nullable=False)
|
||||||
encodings = Column(LargeBinary)
|
encodings = Column(LargeBinary)
|
||||||
|
created_on = Column(Float)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<id: {}, fname: {}, encodings: {}>".format(self.id, self.fname, self.encodings )
|
return f"<id: {id}, fname: {fname}, created_on: {created_on}, encodings: {encodings}>"
|
||||||
|
|
||||||
class File_Person_Link(Base):
|
class File_Person_Link(Base):
|
||||||
__tablename__ = "file_person_link"
|
__tablename__ = "file_person_link"
|
||||||
@@ -545,10 +546,16 @@ def generateUnknownEncodings(im):
|
|||||||
|
|
||||||
def generateKnownEncodings(person):
|
def generateKnownEncodings(person):
|
||||||
for refimg in person.refimg:
|
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)
|
location = face_recognition.face_locations(img)
|
||||||
encodings = face_recognition.face_encodings(img, known_face_locations=location)
|
encodings = face_recognition.face_encodings(img, known_face_locations=location)
|
||||||
refimg.encodings = encodings[0].tobytes()
|
refimg.encodings = encodings[0].tobytes()
|
||||||
|
refimg.created_on = time.time()
|
||||||
session.add(refimg)
|
session.add(refimg)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ create table PERSON ( ID integer, TAG varchar(48), FIRSTNAME varchar(48), SURNAM
|
|||||||
constraint PK_PERSON_ID primary key(ID) );
|
constraint PK_PERSON_ID primary key(ID) );
|
||||||
|
|
||||||
create table REFIMG ( ID integer, FNAME varchar(256), ENCODINGS bytea,
|
create table REFIMG ( ID integer, FNAME varchar(256), ENCODINGS bytea,
|
||||||
|
CREATED_ON fLOAT,
|
||||||
constraint PK_REFIMG_ID primary key(ID) );
|
constraint PK_REFIMG_ID primary key(ID) );
|
||||||
|
|
||||||
create table FILE_PERSON_LINK ( FILE_ID integer, PERSON_ID integer,
|
create table FILE_PERSON_LINK ( FILE_ID integer, PERSON_ID integer,
|
||||||
|
|||||||
Reference in New Issue
Block a user