try/except for os.remove & remove DEBUG. Also deal with odd situation where we find a face then add it as a refimg and library cant find a face all of a sudden

This commit is contained in:
2022-08-08 21:18:01 +10:00
parent c1bb0d3820
commit 497909693c

View File

@@ -105,8 +105,15 @@ def AddRefimgToPerson( filename, person ):
settings = Settings.query.first() settings = Settings.query.first()
model=AIModel.query.get(settings.default_refimg_model) model=AIModel.query.get(settings.default_refimg_model)
refimg.face, face_locn = GenFace( filename, model=model.name ) refimg.face, face_locn = GenFace( filename, model=model.name )
os.remove(filename) try:
os.remove(filename)
except Exception as e:
# can fail "silently" here, if the face_locn worked, great, its only
# a tmp file in /tmp - if not, the next if will send a msg to the front-end
print( f"Failed to delete tmp file for refimg addition: {e}" )
if not face_locn: if not face_locn:
st.SetMessage( f"<b>Failed to find face in Refimg:</b>" )
raise Exception("Could not find face in uploaded reference image" ) raise Exception("Could not find face in uploaded reference image" )
return return
refimg.face_locn = json.dumps(face_locn) refimg.face_locn = json.dumps(face_locn)
@@ -383,7 +390,6 @@ def remove_force_match_override():
FaceForceMatchOverride.query.filter( FaceForceMatchOverride.face_id==face_id ).delete() FaceForceMatchOverride.query.filter( FaceForceMatchOverride.face_id==face_id ).delete()
db.session.commit() db.session.commit()
print( f"person_tag={person_tag}" )
# needed to use person_id in job below (allows consistent processing in job_mgr) # needed to use person_id in job below (allows consistent processing in job_mgr)
p=Person.query.filter(Person.tag==person_tag).one() p=Person.query.filter(Person.tag==person_tag).one()