remove old refimg.encodings generation, we now do this when we make a person/refimg, so its always done before an AI job needs to use it

This commit is contained in:
2021-07-11 22:29:38 +10:00
parent 3dbcf68dad
commit cd6a42088d

View File

@@ -216,13 +216,15 @@ class Refimg(Base):
__tablename__ = "refimg"
id = Column(Integer, Sequence('refimg_id_seq'), primary_key=True )
fname = Column(String(256), unique=True, nullable=False)
face = Column(LargeBinary)
face = Column(LargeBinary, unique=True, nullable=False)
thumbnail = Column(String, unique=False, nullable=True)
encodings = Column(LargeBinary)
created_on = Column(Float)
orig_w = Column(Integer)
orig_h = Column(Integer)
face_locn = Column(String)
def __repr__(self):
return f"<id: {self.id}, fname: {self.fname}, created_on: {self.created_on}, encodings: {self.encodings}>"
return f"<id: {self.id}, fname: {self.fname}, created_on: {self.created_on}>"
class Face(Base):
__tablename__ = "face"
@@ -949,10 +951,6 @@ def JobProcessAI(job):
p = session.query(Path).filter(Path.path_prefix==path).first()
job.num_files=p.num_files
people = session.query(Person).all()
for person in people:
generateKnownEncodings(person)
RunFuncOnFilesInPath( job, path, ProcessAI, True )
FinishJob(job, "Finished Processesing AI")
@@ -1099,22 +1097,6 @@ def generateUnknownEncodings(im):
return unknown_encodings
def generateKnownEncodings(person):
for refimg in person.refimg:
file = 'reference_images/'+refimg.fname
stat = os.stat(file)
if refimg.created_on and stat.st_ctime < refimg.created_on:
print("OPTIM: skipping re-creating encoding for refimg because file has not changed")
continue
img = face_recognition.load_image_file(file)
location = face_recognition.face_locations(img)
encodings = face_recognition.face_encodings(img, known_face_locations=location)
print(f"INFO: created encoding for refimg of {file}")
refimg.encodings = encodings[0].tobytes()
refimg.created_on = time.time()
session.add(refimg)
session.commit()
def compareAI(known_encoding, unknown_encoding):
results = face_recognition.compare_faces([known_encoding], unknown_encoding, tolerance=0.55)
return results