removed all remnants of FILE_REFIMG_LINK

This commit is contained in:
2021-07-03 12:43:25 +10:00
parent a916fb8192
commit 518df7ee10
4 changed files with 6 additions and 54 deletions

13
TODO
View File

@@ -1,5 +1,7 @@
## GENERAL
* remove file_refimg_link stuff...
* refimgs need to be done via job_mgr:
- have local FS chooser of ref img, do html file upload to b/e -> job mgr -> save it to reference_images/<p.tag>/<ref-img-fname>
- remove refimg menu from top-level -> sub of Person (to view/mangage?)
@@ -12,11 +14,11 @@
- remove AI menu from top-level -> make a sub-of Person, and just have Match or AI
(Fix BUG-41 and bits of BUG-43 & TODO: many ref imgs on create person should span multiple rows)
* with any job, count logs, then commit per 100 log lines of a job (and then ditch the commit in import dir for this)
* need AI job to:
log amount matched, amount comparing too -> count should actually be total files in 'entries' (as we can select random entries to check)
* with any job, count logs, then commit per 100 log lines of a job (and then ditch the commit in import dir for this)
* allow rotate of image (permanently on FS, so its right everywhere)
* improve photo browser -> view file, rather than just allowing browser to show image
@@ -26,13 +28,6 @@
* more OO goodness :)
## DB
* Need to think about...
file (image) -> has X faces, Y matches
X == Y (optim: dont scan again)
say X-Y == 1, then to optimise, we need to only check the missing
face... at the moment, the DB structure is not that clever...
(file_refimg_link --> file_refimg_link needs a face_num?)
* Dir can have date in the DB, so we can do Oldest/Newest dirs in Folder view
### BACKEND

View File

@@ -74,15 +74,6 @@ class Entry(db.Model):
def __repr__(self):
return "<id: {}, name: {}, type={}, dir_details={}, file_details={}, in_dir={}>".format(self.id, self.name, self.type, self.dir_details, self.file_details, self.in_dir)
class FileRefimgLink(db.Model):
__tablename__ = "file_refimg_link"
file_id = db.Column(db.Integer, db.ForeignKey('file.eid'), unique=True, nullable=False, primary_key=True)
refimg_id = db.Column(db.Integer, db.ForeignKey('refimg.id'), unique=True, nullable=False, primary_key=True)
when_processed = db.Column(db.Float)
matched = db.Column(db.Boolean)
def __repr__(self):
return f"<file_id: {self.file_id}, refimg_id: {self.refimg_id} when_processed={self.when_processed}, matched={self.matched}"
class File(db.Model):
__tablename__ = "file"
eid = db.Column(db.Integer, db.ForeignKey("entry.id"), primary_key=True )

View File

@@ -150,16 +150,6 @@ class Entry(Base):
def __repr__(self):
return f"<id: {self.id}, name: {self.name}, type={self.type}, exists_on_fs={self.exists_on_fs}, dir_details={self.dir_details}, file_details={self.file_details}, in_dir={self.in_dir}>"
class FileRefimgLink(Base):
__tablename__ = "file_refimg_link"
file_id = Column(Integer, ForeignKey('file.eid'), unique=True, nullable=False, primary_key=True)
refimg_id = Column(Integer, ForeignKey('refimg.id'), unique=True, nullable=False, primary_key=True)
when_processed = Column(Float)
matched = Column(Boolean)
def __repr__(self):
return f"<file_id: {self.file_id}, refimg_id: {self.refimg_id} when_processed={self.when_processed}, matched={self.matched}"
class File(Base):
__tablename__ = "file"
eid = Column(Integer, ForeignKey("entry.id"), primary_key=True )
@@ -533,7 +523,6 @@ def JobForceScan(job):
session.query(FaceFileLink).delete()
session.query(FaceRefimgLink).delete()
session.query(DelFile).delete()
session.query(FileRefimgLink).delete()
session.query(EntryDirLink).delete()
session.query(PathDirLink).delete()
session.query(Path).delete()
@@ -1062,27 +1051,9 @@ def ProcessAI(job, e):
return
def lookForPersonInImage(job, person, unknown_encoding, e):
for refimg in person.refimg:
# lets see if we have tried this check before
frl=session.query(FileRefimgLink).filter(FileRefimgLink.file_id==e.id, FileRefimgLink.refimg_id==refimg.id).first()
if not frl:
frl = FileRefimgLink(refimg_id=refimg.id, file_id=e.file_details.eid)
else:
stat=os.stat( e.FullPathOnFS() )
# file & refimg are not newer then we dont need to check
if frl.matched and stat.st_ctime < frl.when_processed and refimg.created_on < frl.when_processed:
print(f"OPTIM: lookForPersonInImage: file {e.name} has a previous match for: {refimg.fname}, and the file & refimg haven't changed")
return
FinishJob( job, "THIS CODE HAS BEEN REMOVED, need to use new Face* tables, and rethink", "Failed" )
return
session.add(frl)
frl.matched=False
frl.when_processed=time.time()
deserialized_bytes = numpy.frombuffer(refimg.encodings, dtype=numpy.float64)
results = compareAI(deserialized_bytes, unknown_encoding)
if results[0]:
AddLogForJob(job, f'Found a match between: {person.tag} and {e.name}')
frl.matched=True
return
def generateUnknownEncodings(im):
unknown_image = numpy.array(im)

View File

@@ -44,11 +44,6 @@ create table REFIMG ( ID integer, FNAME varchar(256), ENCODINGS bytea,
CREATED_ON float,
constraint PK_REFIMG_ID primary key(ID) );
create table FILE_REFIMG_LINK ( FILE_ID integer, REFIMG_ID integer, WHEN_PROCESSED float, MATCHED boolean,
constraint PK_FRL primary key(FILE_ID, REFIMG_ID),
constraint FK_FRL_FILE_ID foreign key (FILE_ID) references FILE(EID),
constraint FK_FRL_REFIMG_ID foreign key (REFIMG_ID) references REFIMG(ID) );
create table FACE( ID integer, FACE bytea, constraint PK_FACE_ID primary key(ID) );
create table FACE_FILE_LINK( FACE_ID integer, FILE_EID integer,