Skip to content

Commit 210d3f0

Browse files
committed
add some testing code for auto recognition
1 parent 6f0ab20 commit 210d3f0

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

deep.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from deepface import DeepFace
2+
from PIL import Image
3+
import numpy as np
4+
import pandas as pd
5+
6+
pd.set_option('display.max_colwidth', -1)
7+
8+
db_path = "/home/collin/Web/piwigo/plugins/MugShot/training"
9+
10+
target_img = "/home/collin/Downloads/IMG_8069.jpg"
11+
12+
backends = ['opencv', 'ssd', 'dlib', 'mtcnn', 'retinaface']
13+
14+
#face detection and alignment
15+
detected_face = DeepFace.detectFace(target_img, detector_backend = backends[4])
16+
17+
#face recognition
18+
#df = DeepFace.find(target_img, db_path, detector_backend = backends[4])
19+
20+
#Convert array to image
21+
images = Image.fromarray(detected_face)
22+
23+
# Display image
24+
for image in images:
25+
image.show()
26+
27+
print(detected_face)

include/capture.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function book_mugshots($data, &$service) {
4242
}
4343

4444
$imageId = pwg_db_real_escape_string($data['imageId']);
45-
$plugin_config = unserialize(conf_get_param(MUGSHOT_ID));
45+
$plugin_config = conf_get_param(MUGSHOT_ID);
4646

4747
unset($data['imageId']);
4848
$imageIdTagIdInsertionString = ''; //
@@ -70,9 +70,9 @@ function book_mugshots($data, &$service) {
7070

7171
// If it's a brand new tag, we won't have sent a tag ID back with the data.
7272
$newTagId = ($existingTagId == -1) ? tag_id_from_tag_name($labeledTagName) : $existingTagId;
73-
73+
var_dump($plugin_config);
7474
// Create or remove the training thumbnails, depending on webmaster settings.
75-
if ($plugin_config['autotag']) {
75+
if ($plugin_config['autotag'] == '1') {
7676
$sql = "SELECT * FROM `". IMAGES_TABLE . "` WHERE `id`=".$imageId.";";
7777

7878
$imgData = pwg_db_fetch_assoc(pwg_query($sql));

include/helpers.php

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function create_tag_group() {
2525
if ($result == 0)
2626
{
2727
$makeTaggerGroupQuery = "INSERT INTO " . GROUPS_TABLE . ' (name) VALUES ("Taggers")';
28+
2829
pwg_query($makeTaggerGroupQuery);
2930

3031
$result = fetch_sql($checkTaggerGroupQuery, 'id', false);

main.inc.php

+27-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
define('MUGSHOT_BASE_URL', get_root_url() . 'admin.php?page=plugin-' . MUGSHOT_ID);
3030
define('MUGSHOT_VERSION', '2.0.2');
3131
define('MUGSHOT_TABLE', '`face_tag_positions`');
32+
define('MUGSHOT_QUEUE_TABLE', '`face_tag_queue`');
3233

3334

3435
/*
@@ -43,6 +44,7 @@
4344
add_event_handler('init', 'mugshot_lang_init');
4445
add_event_handler('loc_begin_page_header', 'mugshot_files', 40, 2);
4546
add_event_handler('loc_end_picture', 'mugshot_button');
47+
add_event_handler('loc_end_add_uploaded_file', 'mugshot_queue_for_processing');
4648

4749
/*
4850
* Include custom helper functions
@@ -96,6 +98,30 @@
9698
define('MUGSHOT_USER_ADMIN', false);
9799
}
98100

101+
/*
102+
* Test to see if the upload fires as expected
103+
*/
104+
function create_facetag_tableb() {
105+
106+
107+
}
108+
109+
function mugshot_queue_for_processing($image_info) {
110+
$createTableQuery = 'CREATE TABLE IF NOT EXISTS `face_tag_queue` (
111+
`image_id` mediumint(8) unsigned NOT NULL default "0",
112+
`stuff` varchar(5000) NOT NULL default "0",
113+
PRIMARY KEY (`image_id`)
114+
)';
115+
116+
pwg_query($createTableQuery);
117+
118+
$item = serialize($image_info);
119+
$id = $image_info['id'];
120+
121+
$insertImageQueueQuery = "INSERT INTO `face_tag_queue` (image_id, stuff) VALUES ('$id','$item')";
122+
123+
pwg_query($insertImageQueueQuery);
124+
}
99125

100126
/*
101127
* Loads translations
@@ -244,7 +270,7 @@ function insert_tag_list() {
244270

245271
global $template;
246272

247-
$plugin_config = unserialize(conf_get_param(MUGSHOT_ID));
273+
$plugin_config = conf_get_param(MUGSHOT_ID);
248274

249275
$max_tags = $plugin_config['max_tags'] ?? 500;
250276

0 commit comments

Comments
 (0)