From 694aef038bd42e4ef75399c029e8278877f0d99b Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Fri, 4 Feb 2022 22:03:04 +1100 Subject: [PATCH] if we use run_ai_on_path, then we remove all existing matches on the path, then go again -- allows us to change threshold and reset --- pa_job_manager.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pa_job_manager.py b/pa_job_manager.py index 9b5d77c..66e4dc0 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -1449,6 +1449,7 @@ def JobRunAIOnPath(job): path_cnt=0 for p in paths: d = session.query(Dir).join(PathDirLink).filter(PathDirLink.path_id==p.id).filter(Dir.rel_path=='').first() + DelMatchesForDir( job, d.eid ) job.extra.append( JobExtra( name=f"eid-{path_cnt}", value=f"{d.eid}" ) ) path_cnt+=1 JobRunAIOn(job) @@ -1927,6 +1928,28 @@ def AddFaceToFile( locn_data, face_data, file_eid, model_id, settings ): session.commit() return +#################################################################################################################################### +# DelMatchesForDir(): quick func to delete any matched faces in the specified dir +#################################################################################################################################### +def DelMatchesForDir( job, eid ): + print("Recurse through dirs deleting face per file" ) + dir=session.query(Entry).get(eid) + ProcessFilesInDir( job, dir, DelMatchesForFile, False ) + session.commit() + return + +#################################################################################################################################### +# DelMatchesForFile(): quick func to delete any matched faces associated with the specified file +#################################################################################################################################### +def DelMatchesForFile( job, ent ): + if DEBUG: + AddLogForJob(job, f'Remove any old matches in {ent.name}') + + session.execute( f"delete from face_refimg_link where face_id in (select face_id from face_file_link where file_eid = {ent.id})" ) + ent.file_details.last_ai_scan=0 + session.add(ent) + return + #################################################################################################################################### # DelFacesForFile(): quick func to delete any faces associated with the specified file ####################################################################################################################################