diff --git a/TODO b/TODO index cb3b98c..da89d12 100644 --- a/TODO +++ b/TODO @@ -1,15 +1,9 @@ ## GENERAL * get build process to create a random string for secret for PROD, otherwise use builtin for dev - * lighthouse -> check in PROD, all ssl / viewer works? - * comment your code * html files? - * person->ai stats... - * definitely make be a clickable link to search on AI: - * probably more cols of data to squish more on a page? - * per file you could select an unknown face and add it as a ref img to an existing person, or make a new person and attach? * from menu, we could try to get smart/fancy... say find face with largest size, check it vs. other faces, if it matches more than say 10? we offer it up as a required ref img, then cut that face (with margin) out and use it is a new ref image / person - read that guys face matching / clustering / nearest neighbour examples, for a whole new AI capability diff --git a/ai.py b/ai.py index 3c30262..94d0074 100644 --- a/ai.py +++ b/ai.py @@ -22,6 +22,9 @@ from face import Face, FaceFileLink, FaceRefimgLink @login_required def aistats(): stats = db.session.execute( "select p.tag, count(f.id) from person p, face f, face_file_link ffl, face_refimg_link frl, person_refimg_link prl where p.id = prl.person_id and prl.refimg_id = frl.refimg_id and frl.face_id = ffl.face_id and ffl.face_id = f.id group by p.tag" ) + cnt_res = db.session.execute( "select count(1) from ( select p.tag from person p, face f, face_file_link ffl, face_refimg_link frl, person_refimg_link prl where p.id = prl.person_id and prl.refimg_id = frl.refimg_id and frl.face_id = ffl.face_id and ffl.face_id = f.id group by p.tag ) as foo" ) + num_stats=cnt_res.first()[0] + fstats={} fstats['files_with_a_face'] = db.session.execute( "select count(distinct file_eid) as count from face_file_link" ).first()[0] fstats['files_with_a_match'] = db.session.execute( "select count(distinct ffl.file_eid) as count from face_file_link ffl, face_refimg_link frl where frl.face_id = ffl.face_id" ).first()[0] @@ -33,7 +36,7 @@ def aistats(): fstats['all_matched_faces'] = db.session.execute( "select count(distinct face_id) as count from face_refimg_link" ).first()[0] fstats['all_unmatched_faces'] = db.session.execute( "select count(f.id) from face f left join face_refimg_link frl on f.id = frl.face_id where frl.refimg_id is null" ).first()[0] - return render_template("aistats.html", page_title='AI Statistics', stats=stats, fstats=fstats ) + return render_template("aistats.html", page_title='AI Statistics', stats=stats, num_stats=num_stats, fstats=fstats ) ################################################################################ diff --git a/person.py b/person.py index 9186447..74d5f26 100644 --- a/person.py +++ b/person.py @@ -147,7 +147,6 @@ def person(id): new_refs.append(ref_img) if new_refs != person.refimg: deld = list(set(person.refimg) - set(new_refs)); - print(deld) person.refimg = new_refs Refimg.query.filter(Refimg.id==deld[0].id).delete() st.SetMessage( f"Successfully Updated Person: removed reference image {deld[0].fname}" ) diff --git a/templates/aistats.html b/templates/aistats.html index d43244b..c62909d 100644 --- a/templates/aistats.html +++ b/templates/aistats.html @@ -1,21 +1,63 @@ {% extends "base.html" %} {% block main_content %} +

Basic AI stats

- - - - - - - - -
WhatAmount
Files with a face{{fstats['files_with_a_face']}}
Files with a matched face{{fstats['files_with_a_match']}}
Files with missing matches{{fstats['files_with_missing_matches']}}
All faces found{{fstats['all_faces']}}
All faces matched{{fstats['all_matched_faces']}}
All faces unmatched{{fstats['all_unmatched_faces']}}
+
+
What
Amount
+
+
Files with a face
{{fstats['files_with_a_face']}}
+
+
Files with a face
{{fstats['files_with_a_face']}}
+
+
Files with a matched face
{{fstats['files_with_a_match']}}
+
+
Files with missing matches
{{fstats['files_with_missing_matches']}}
+
+
All faces found
{{fstats['all_faces']}}
+
+
All faces matched
{{fstats['all_matched_faces']}}
+
+
All faces unmatched
{{fstats['all_unmatched_faces']}}
+
- - +
+ {% if num_stats > 0 %} +
Person
# matches
+ {% endif %} + {% if num_stats > 1 %} +
Person
# matches
+ {% endif %} + {% if num_stats > 2 %} +
Person
# matches
+ {% endif %} + {% if num_stats > 3 %} +
Person
# matches
+ {% endif %} +
+
{% for s in stats %} -
+
+
+ + + + + + + + + {{s[0]}} +
+
{{s[1]}}
+
+ {% if loop.index + 1 % 3 == 0 %} +
+ {% endif %} {% endfor %} -
Person (tag)Number of files matched
{{s[0]}}{{s[1]}}
+ {% endblock main_content %}