From d579b257a874a337801fc5ac7b72ee1d9201dce5 Mon Sep 17 00:00:00 2001 From: Stephan Bolten Date: Wed, 6 May 2020 18:57:50 +0200 Subject: [PATCH 1/2] Added "People" category to tag routine Added field in GUI to provide "People" category Changed label of tag category Changed Tooltip --- contrib/face_recognition.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/face_recognition.lua b/contrib/face_recognition.lua index 449b399..89b2041 100644 --- a/contrib/face_recognition.lua +++ b/contrib/face_recognition.lua @@ -139,6 +139,7 @@ local function save_preferences() dt.preferences.write(MODULE, "unknown_tag", "string", fc.unknown_tag.text) dt.preferences.write(MODULE, "no_persons_found_tag", "string", fc.no_persons_found_tag.text) dt.preferences.write(MODULE, "ignore_tags", "string", fc.ignore_tags.text) + dt.preferences.write(MODULE, "category_tags", "string", fc.category_tags.text) dt.preferences.write(MODULE, "known_image_path", "directory", fc.known_image_path.value) local val = fc.tolerance.value val = string.gsub(tostring(val), ",", ".") @@ -153,6 +154,7 @@ local function reset_preferences() fc.unknown_tag.text = "unknown_person" fc.no_persons_found_tag.text = "no_persons_found" fc.ignore_tags.text = "" + fc.category_tags.text = "People" fc.known_image_path.value = dt.configuration.config_dir .. "/face_recognition" fc.tolerance.value = 0.6 fc.num_cores.value = -1 @@ -203,6 +205,7 @@ local function face_recognition () local knownPath = dt.preferences.read(MODULE, "known_image_path", "directory") local nrCores = dt.preferences.read(MODULE, "num_cores", "integer") local ignoreTagString = dt.preferences.read(MODULE, "ignore_tags", "string") + local categoryTagString = dt.preferences.read(MODULE, "category_tags", "string") local unknownTag = dt.preferences.read(MODULE, "unknown_tag", "string") local nonpersonsfoundTag = dt.preferences.read(MODULE, "no_persons_found_tag", "string") @@ -303,6 +306,9 @@ local function face_recognition () t = nonpersonsfoundTag end if t ~= "" and t ~= nil then + if categoryTagString ~= "" then + t = categoryTagString .. "|" .. t + end dt.print_log ("ImgId:" .. img.id .. " Tag:".. t) -- Create tag if it does not exist if tags_list[t] == nil then @@ -351,6 +357,12 @@ fc.ignore_tags = dt.new_widget("entry"){ editable = true, } +fc.category_tags = dt.new_widget("entry"){ + text = dt.preferences.read(MODULE, "category_tags", "string"), + tooltip = _("tag category"), + editable = true, +} + fc.tolerance = dt.new_widget("slider"){ label = _("tolerance"), tooltip = ("detection tolerance - 0.6 default - lower if too many faces detected"), @@ -421,6 +433,8 @@ local widgets = { fc.no_persons_found_tag, dt.new_widget("label"){ label = _("tags of images to ignore")}, fc.ignore_tags, + dt.new_widget("label"){ label = _("tag category")}, + fc.category_tags, dt.new_widget("label"){ label = _("face data directory")}, fc.known_image_path, } From 54a66f9ab21aa78dc74197c512ab993836cd70ea Mon Sep 17 00:00:00 2001 From: Stephan Bolten Date: Sat, 9 May 2020 19:58:57 +0200 Subject: [PATCH 2/2] Category Tag default & no_person_found 1 - empty by default 2 - not added when no_person_found --- contrib/face_recognition.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/face_recognition.lua b/contrib/face_recognition.lua index 89b2041..26caff6 100644 --- a/contrib/face_recognition.lua +++ b/contrib/face_recognition.lua @@ -154,7 +154,7 @@ local function reset_preferences() fc.unknown_tag.text = "unknown_person" fc.no_persons_found_tag.text = "no_persons_found" fc.ignore_tags.text = "" - fc.category_tags.text = "People" + fc.category_tags.text = "" fc.known_image_path.value = dt.configuration.config_dir .. "/face_recognition" fc.tolerance.value = 0.6 fc.num_cores.value = -1 @@ -306,7 +306,7 @@ local function face_recognition () t = nonpersonsfoundTag end if t ~= "" and t ~= nil then - if categoryTagString ~= "" then + if categoryTagString ~= "" and t ~= nonpersonsfoundTag then t = categoryTagString .. "|" .. t end dt.print_log ("ImgId:" .. img.id .. " Tag:".. t)