removing extra session.commits, and optimsing run_ai_on - dont reprocess faces if no new refimgs since last scan -- so we had set last_ai_scan on FILE as well
This commit is contained in:
@@ -19,7 +19,7 @@ DEBUG=1
|
|||||||
|
|
||||||
### SQLALCHEMY IMPORTS ###
|
### SQLALCHEMY IMPORTS ###
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy import Column, Integer, String, Sequence, Float, ForeignKey, DateTime, LargeBinary, Boolean
|
from sqlalchemy import Column, Integer, String, Sequence, Float, ForeignKey, DateTime, LargeBinary, Boolean, func
|
||||||
from sqlalchemy.exc import SQLAlchemyError
|
from sqlalchemy.exc import SQLAlchemyError
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
@@ -193,6 +193,7 @@ class File(Base):
|
|||||||
day = Column(Integer)
|
day = Column(Integer)
|
||||||
woy = Column(Integer)
|
woy = Column(Integer)
|
||||||
last_hash_date = Column(Float)
|
last_hash_date = Column(Float)
|
||||||
|
last_ai_scan = Column(Float)
|
||||||
faces = Column( LargeBinary )
|
faces = Column( LargeBinary )
|
||||||
faces_created_on = Column(Float)
|
faces_created_on = Column(Float)
|
||||||
|
|
||||||
@@ -754,7 +755,6 @@ def JobForceScan(job):
|
|||||||
ProcessStorageDirs(job)
|
ProcessStorageDirs(job)
|
||||||
FinishJob(job, "Completed (forced remove and recreation of all file data)")
|
FinishJob(job, "Completed (forced remove and recreation of all file data)")
|
||||||
MessageToFE( job.id, "success", "Completed (forced remove and recreation of all file data)" )
|
MessageToFE( job.id, "success", "Completed (forced remove and recreation of all file data)" )
|
||||||
session.commit()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@@ -1674,7 +1674,6 @@ def MatchRefimgToFace( refimg_id, face_id, face_dist ):
|
|||||||
session.query(FaceRefimgLink).filter(FaceRefimgLink.face_id==face_id).delete()
|
session.query(FaceRefimgLink).filter(FaceRefimgLink.face_id==face_id).delete()
|
||||||
rfl = FaceRefimgLink( refimg_id = refimg_id, face_id = face_id, face_distance=face_dist )
|
rfl = FaceRefimgLink( refimg_id = refimg_id, face_id = face_id, face_distance=face_dist )
|
||||||
session.add(rfl)
|
session.add(rfl)
|
||||||
session.commit()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
@@ -1764,11 +1763,18 @@ def ScanFileForPerson( job, e, force=False ):
|
|||||||
for locn, face in zip( face_locations, unknown_encodings ):
|
for locn, face in zip( face_locations, unknown_encodings ):
|
||||||
AddFaceToFile( locn, face, e.id, model.id )
|
AddFaceToFile( locn, face, e.id, model.id )
|
||||||
file_h.faces_created_on = time.time()
|
file_h.faces_created_on = time.time()
|
||||||
session.commit()
|
|
||||||
|
|
||||||
faces = session.query(Face).join(FaceFileLink).filter(FaceFileLink.file_eid==e.id).all()
|
faces = session.query(Face).join(FaceFileLink).filter(FaceFileLink.file_eid==e.id).all()
|
||||||
# if there are no faces for this file, then dont go any futher
|
# if there are no faces for this file, then dont go any futher
|
||||||
if not faces:
|
if not faces:
|
||||||
|
file_h.last_ai_scan = time.time()
|
||||||
|
return
|
||||||
|
|
||||||
|
ri_newest = session.query(func.max(Refimg.created_on)).first()[0]
|
||||||
|
|
||||||
|
# ri_newest has to exist, no ris and we dont process files but, if we have never scanned before, then last_ai_scan will be None
|
||||||
|
# if last_ai_scan is newer than the most recent refimg created, no need to look again, we have checked those refimgs in the last scan, just skip this file
|
||||||
|
if file_h.last_ai_scan and file_h.last_ai_scan > ri_newest:
|
||||||
return
|
return
|
||||||
|
|
||||||
dist={}
|
dist={}
|
||||||
@@ -1784,6 +1790,7 @@ def ScanFileForPerson( job, e, force=False ):
|
|||||||
|
|
||||||
# record matches in DB...
|
# record matches in DB...
|
||||||
ProcessFaceMatches( job, dist, threshold, e, name )
|
ProcessFaceMatches( job, dist, threshold, e, name )
|
||||||
|
file_h.last_ai_scan = time.time()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user