updated job manager to (theoretically) work for ai, but i havent tested the comparison code yet
This commit is contained in:
@@ -952,8 +952,12 @@ def WrapperForScanFileForPerson(job, entry):
|
|||||||
ppl=session.query(Person).all()
|
ppl=session.query(Person).all()
|
||||||
else:
|
else:
|
||||||
ppl=session.query(Person).filter(Person.tag==which_person).all()
|
ppl=session.query(Person).filter(Person.tag==which_person).all()
|
||||||
for person in ppl:
|
|
||||||
print( f"(wrapper) call == ScanFileForPerson( {entry.id}, {person.id}, force=False )" )
|
if entry.type.name == 'Image':
|
||||||
|
print( f"JobRunAIOn: file to process had id: {entry.id}" )
|
||||||
|
for person in ppl:
|
||||||
|
print( f"call == ScanFileForPerson( {entry.id}, {person.id}, force=False )" )
|
||||||
|
ScanFileForPerson( entry, person.id, force=False)
|
||||||
return
|
return
|
||||||
|
|
||||||
def JobRunAIOn(job):
|
def JobRunAIOn(job):
|
||||||
@@ -970,7 +974,7 @@ def JobRunAIOn(job):
|
|||||||
for jex in job.extra:
|
for jex in job.extra:
|
||||||
if 'eid-' in jex.name:
|
if 'eid-' in jex.name:
|
||||||
entry=session.query(Entry).get(jex.value)
|
entry=session.query(Entry).get(jex.value)
|
||||||
print( f'en={entry}' )
|
print( f'en={entry.name}, {entry.type.name}' )
|
||||||
if entry.type.name == 'Directory':
|
if entry.type.name == 'Directory':
|
||||||
ProcessFilesInDir( job, entry, WrapperForScanFileForPerson )
|
ProcessFilesInDir( job, entry, WrapperForScanFileForPerson )
|
||||||
elif entry.type.name == 'Image':
|
elif entry.type.name == 'Image':
|
||||||
@@ -978,10 +982,11 @@ def JobRunAIOn(job):
|
|||||||
print( f"JobRunAIOn: file to process had id: {which_file.id}" )
|
print( f"JobRunAIOn: file to process had id: {which_file.id}" )
|
||||||
for person in ppl:
|
for person in ppl:
|
||||||
print( f"call == ScanFileForPerson( {which_file.id}, {person.id}, force=False )" )
|
print( f"call == ScanFileForPerson( {which_file.id}, {person.id}, force=False )" )
|
||||||
|
ScanFileForPerson( which_file, person.id, force=False)
|
||||||
else:
|
else:
|
||||||
AddLogForJob( job, f'Not processing Entry: {entry.name} - not an image' )
|
AddLogForJob( job, f'Not processing Entry: {entry.name} - not an image' )
|
||||||
print(" HARD EXITING to keep testing " )
|
#print(" HARD EXITING to keep testing " )
|
||||||
exit( -1 )
|
#exit( -1 )
|
||||||
FinishJob(job, "Finished Processesing AI")
|
FinishJob(job, "Finished Processesing AI")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1011,7 +1016,7 @@ def ProcessAI(job, e):
|
|||||||
job.current_file_num+=1
|
job.current_file_num+=1
|
||||||
return
|
return
|
||||||
|
|
||||||
file = e.FullPathOnFS()
|
file = e.FullPathOnFS()
|
||||||
stat = os.stat(file)
|
stat = os.stat(file)
|
||||||
# find if file is newer than when we found faces before (fyi: first time faces_created_on == 0)
|
# find if file is newer than when we found faces before (fyi: first time faces_created_on == 0)
|
||||||
if stat.st_ctime > e.file_details.faces_created_on:
|
if stat.st_ctime > e.file_details.faces_created_on:
|
||||||
@@ -1101,7 +1106,7 @@ def compareAI(known_encoding, unknown_encoding):
|
|||||||
def ProcessFilesInDir(job, e, file_func):
|
def ProcessFilesInDir(job, e, file_func):
|
||||||
if DEBUG==1:
|
if DEBUG==1:
|
||||||
print( f"???? e={e}" )
|
print( f"???? e={e}" )
|
||||||
print( f"DEBUG: ProcessFilesInDir: {e.FullPathOnFS()}")
|
# print( f"DEBUG: ProcessFilesInDir: {e.FullPathOnFS()}")
|
||||||
if e.type.name != 'Directory':
|
if e.type.name != 'Directory':
|
||||||
file_func(job, e)
|
file_func(job, e)
|
||||||
else:
|
else:
|
||||||
@@ -1411,32 +1416,39 @@ def UnmatchedFacesForFile( eid ):
|
|||||||
return rows
|
return rows
|
||||||
|
|
||||||
### CAM: something like this -- HAVE NOT TRIED THIS IT WILL FAIL###
|
### CAM: something like this -- HAVE NOT TRIED THIS IT WILL FAIL###
|
||||||
def ScanFileForPerson( eid, person_id, force=False ):
|
def ScanFileForPerson( e, person_id, force=False ):
|
||||||
file_h = session.query(File).get( eid )
|
file_h = session.query(File).get( e.id )
|
||||||
# if we are forcing this, delete any old faces (this will also delete linked tables), and reset faces_created_on to None
|
# if we are forcing this, delete any old faces (this will also delete linked tables), and reset faces_created_on to None
|
||||||
if force:
|
if force:
|
||||||
DelFacesForFile( eid )
|
DelFacesForFile( e.id )
|
||||||
file_h.faces_create_on = None
|
file_h.faces_create_on = None
|
||||||
|
|
||||||
# optimise: dont rescan if we already have faces (we are just going to try
|
# optimise: dont rescan if we already have faces (we are just going to try
|
||||||
# to match (maybe?) a refimg
|
# to match (maybe?) a refimg
|
||||||
if not file_h.faces_created_on:
|
if not file_h.faces_created_on:
|
||||||
# CAM: TODO: add Face Rec code to get unknown encodings
|
print("------------- CAM -----------:\n")
|
||||||
|
im = face_recognition.load_image_file(e.FullPathOnFS())
|
||||||
|
print(im)
|
||||||
|
face_locations = face_recognition.face_locations(im)
|
||||||
|
print(f"FACE LOCATIONS: {face_locations}")
|
||||||
|
unknown_encodings = face_recognition.face_encodings(im, known_face_locations=face_locations)
|
||||||
|
print("AAAAAAAAAAAAAAAA " + str(len(unknown_encodings)))
|
||||||
for face in unknown_encodings:
|
for face in unknown_encodings:
|
||||||
new_face = Face( face_data = face )
|
new_face = Face( face_data = face )
|
||||||
session.add(new_face)
|
session.add(new_face)
|
||||||
session.commit()
|
session.commit()
|
||||||
AddFaceToFile( new_face.id, eid )
|
AddFaceToFile( new_face.id, e.id )
|
||||||
now=datetime.now(pytz.utc)
|
now=datetime.now(pytz.utc)
|
||||||
file_h.face_created_on = now
|
file_h.face_created_on = now
|
||||||
|
|
||||||
## now look for person
|
## now look for person
|
||||||
refimgs = session.query(Refimg).join(PersonRefimgLink).filter(PersonRefimgLink.person_id==person_id).all()
|
refimgs = session.query(Refimg).join(PersonRefimgLink).filter(PersonRefimgLink.person_id==person_id).all()
|
||||||
uf = UnmatchedFacesForFile( eid )
|
uf = UnmatchedFacesForFile( e.id )
|
||||||
for face in uf:
|
for face in uf:
|
||||||
for r in refimgs:
|
for r in refimgs:
|
||||||
# CAM: TODO: add Face rec code to see if there is match
|
match = compareAI(r, uf)
|
||||||
if match:
|
if match:
|
||||||
|
print(f'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA WE MATCHED: {r}, {uf}')
|
||||||
MatchRefimgToFace( r.id, face.id )
|
MatchRefimgToFace( r.id, face.id )
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user