Skip to content

Feature/face detection#19

Merged
ratzdi merged 8 commits into
masterfrom
feature/face_detection
Jun 19, 2026
Merged

Feature/face detection#19
ratzdi merged 8 commits into
masterfrom
feature/face_detection

Conversation

@ratzdi

@ratzdi ratzdi commented Apr 28, 2026

Copy link
Copy Markdown
Owner

No description provided.

ratzdi added 3 commits April 17, 2026 13:55
This commit introduces an optional ONNX face-detection backend, configurable via the PICMAG_FACE_DETECTION_MODEL environment variable. When enabled, the system can detect multiple faces in an image using a specified ONNX model, with configurable detection thresholds, NMS IoU thresholds, and maximum number of faces.

Key changes include:

PersonRecognition.cs:
Integration of OnnxDetectionRuntime for multi-face detection.
Implementation of non-maximum suppression (NMS) and Intersection over Union (IoU) for refining detection results.
Fallback to a single centered face region if ONNX detection fails or no faces are detected above the threshold.
New environment variables for configuring detection parameters: PICMAG_FACE_DETECTION_THRESHOLD, PICMAG_FACE_DETECTION_NMS_IOU, PICMAG_FACE_DETECTION_MAX_FACES.
LooksLikeEmbeddingModelPath now checks if the configured detection model path resembles an embedding model to prevent misconfiguration.
CreateFallbackEmbedding generates unique fallback embeddings for multiple faces.
Program.CommandHandlers.cs:
Enhanced person scan report to include fallback_files count and detailed fallback_reasons for cases where ONNX detection or embedding falls back to simpler methods.
CHANGELOG.md: Updated to reflect the new ONNX face-detection backend feature.
This significantly enhances the person-scan-existing command by providing more robust face detection capabilities and better insights into the analysis process, especially when external ONNX models are utilized.
@ratzdi ratzdi force-pushed the feature/face_detection branch from 00a7a7d to 730e3c6 Compare May 5, 2026 19:31
@ratzdi ratzdi linked an issue May 6, 2026 that may be closed by this pull request
Copilot AI review requested due to automatic review settings June 9, 2026 06:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an MVP person-recognition workflow to picmag (face detection + optional ONNX embeddings, SQLite persistence, and CLI commands) and reorganizes documentation/testing to support the new feature set.

Changes:

  • Add person-recognition storage tables and CLI commands (--person-*) including scan/label/train/predict/review flows.
  • Add unit + integration test coverage for the persistence/CLI workflow, plus dataset tooling and attribution manifest scaffolding.
  • Rework top-level README into a quick start and add dedicated docs pages; add CI license-header checking.

Reviewed changes

Copilot reviewed 29 out of 34 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
unittests/QualityAnalyzerTests.cs Adds MIT license header to unit test file.
unittests/PersonRecognitionTablesTests.cs Adds new unit tests for person recognition tables/workflows.
unittests/ImagesTableTests.cs Adds MIT license header to unit test file.
unittests/GlobalUsings.cs Adds MIT license header to unit test global usings.
scripts/download_person_test_images.py Adds a script to download person images + write an attribution TSV manifest.
scripts/check_license_headers.py Adds a script to enforce license headers across source files.
README.md Replaces full README with a quick-start and links to dedicated docs.
picmag/tests/integration_test.sh Adds an end-to-end person recognition integration test (dataset-gated).
picmag/tests/in/5-person/train/.gitkeep Keeps dataset directory in git without committing images.
picmag/tests/in/5-person/README.md Documents how to provide a local dataset for the person-recognition integration test.
picmag/tests/in/5-person/probe/.gitkeep Keeps dataset directory in git without committing images.
picmag/tests/in/5-person/probe-negative/.gitkeep Keeps dataset directory in git without committing images.
picmag/tests/in/5-person/LICENSES.tsv Adds an attribution manifest for test images.
picmag/src/QualityAnalysis.cs Adds MIT license header to existing source file.
picmag/src/Program.cs Extends CLI usage output with --person-* commands.
picmag/src/Program.CommandParser.cs Parses new person-recognition CLI commands and flags.
picmag/src/Program.CommandHandlers.cs Implements handlers for scan/add/list/label/search/train/predict/review.
picmag/src/PersonsTable.cs Adds persons table + helper methods.
picmag/src/PersonRecognition.cs Adds face detection + optional ONNX embedding runtime and helper logic.
picmag/src/PersonProfilesTable.cs Adds persistence for per-person embedding profiles.
picmag/src/PersonPredictionsTable.cs Adds persistence for predicted person matches and review status.
picmag/src/ImageFacesTable.cs Adds persistence for detected faces + labels + queries for training/prediction.
picmag/src/Database.cs Wires new tables into the Database façade.
picmag/picmag.csproj Bumps version to 0.6.0; adds OnnxRuntime dependency and bundles detector model.
picmag/completions/picmag.bash-completion Extends bash completion for new --person-* commands.
docs/shell-completion.md Adds standalone shell completion documentation.
docs/readme-standard.md Restores the “standard” full README as a separate doc.
docs/person-recognition.md Adds detailed person recognition workflow documentation.
docs/packaging.md Adds packaging documentation page.
docs/cli.md Adds consolidated CLI reference page.
CHANGELOG.md Adds 0.6.0 release notes describing person recognition and license checks.
.gitignore Ignores local real-person dataset images while keeping .gitkeep files.
.github/workflows/dotnet.yml Adds a CI step to check license headers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +50 to +54
cmd.CommandText = @"create table if not exists persons(
id integer primary key autoincrement,
name text not null unique,
created_at integer not null
);";
Comment thread picmag/src/Program.CommandHandlers.cs
Comment on lines +324 to +328
else if (args[i].StartsWith("-"))
{
return false;
}
}
Comment thread picmag/src/PersonRecognition.cs
Comment on lines +912 to +914
private static readonly object sync = new object();
private static OnnxDetectionRuntime instance;
private static bool initialized;
Comment on lines +149 to +151
lines.append(
f'{target.name}\t{title}\t{url}\t{license_name}\t{license_url}\t{artist}'
)
Comment on lines +9 to +10
obama_probe_02.jpg File:Barack Obama and Gordon Brown in 10 Downing Street.jpg https://upload.wikimedia.org/wikipedia/commons/8/8d/Barack_Obama_and_Gordon_Brown_in_10_Downing_Street.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original Public domain <div class="fn value">
<a rel="nofollow" class="external text" href="https://www.flickr.com/people/35591378@N03">The Official White House Photostream</a></div>
Comment on lines +14 to +18
other_probe_01.jpg Angela Merkel portrait File:Angela Merkel. Tallinn Digital Summit.jpg https://upload.wikimedia.org/wikipedia/commons/b/bf/Angela_Merkel._Tallinn_Digital_Summit.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original CC BY 2.0 https://creativecommons.org/licenses/by/2.0 <a rel="nofollow" class="external text" href="https://www.flickr.com/people/145047505@N06">EU2017EE Estonian Presidency</a>
other_probe_02.jpg Joe Biden portrait File:Joe Biden in 1968 Edition of Onondagan Yearbook.jpg https://upload.wikimedia.org/wikipedia/commons/e/ec/Joe_Biden_in_1968_Edition_of_Onondagan_Yearbook.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original Public domain Syracuse University
other_probe_03.jpg Joe Biden portrait File:Joe Biden presidential portrait.jpg https://upload.wikimedia.org/wikipedia/commons/6/68/Joe_Biden_presidential_portrait.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original Public domain <bdi><a href="https://en.wikipedia.org/wiki/en:Adam_Schultz" class="extiw" title="w:en:Adam Schultz"><span title="American photographer">Adam Schultz</span></a></bdi>
other_probe_04.jpg Emmanuel Macron portrait File:Emmanuel Macron (cropped).jpg https://upload.wikimedia.org/wikipedia/commons/c/c3/Emmanuel_Macron_%28cropped%29.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original CC BY 2.0 https://creativecommons.org/licenses/by/2.0 <a rel="nofollow" class="external text" href="https://www.flickr.com/people/145047505@N06">Arno Mikkor, EU2017EE Estonian Presidency</a>
other_probe_05.jpg Emmanuel Macron portrait File:Emmanuel Macron - June 2025 (3x4 cropped).jpg https://upload.wikimedia.org/wikipedia/commons/4/47/Emmanuel_Macron_-_June_2025_%283x4_cropped%29.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original CC BY 4.0 https://creativecommons.org/licenses/by/4.0 <a href="https://en.wikipedia.org/wiki/European_Commission" class="extiw" title="w:European Commission">European Commission</a>
Comment on lines +19 to +23
other_probe_01.jpg File:Angela Merkel. Tallinn Digital Summit.jpg https://upload.wikimedia.org/wikipedia/commons/b/bf/Angela_Merkel._Tallinn_Digital_Summit.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original CC BY 2.0 https://creativecommons.org/licenses/by/2.0 <a rel="nofollow" class="external text" href="https://www.flickr.com/people/145047505@N06">EU2017EE Estonian Presidency</a>
other_probe_02.jpg File:Emmanuel Macron (cropped).jpg https://upload.wikimedia.org/wikipedia/commons/c/c3/Emmanuel_Macron_%28cropped%29.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original CC BY 2.0 https://creativecommons.org/licenses/by/2.0 <a rel="nofollow" class="external text" href="https://www.flickr.com/people/145047505@N06">Arno Mikkor, EU2017EE Estonian Presidency</a>
other_probe_03.jpg File:Emmanuel Macron - June 2025 (3x4 cropped).jpg https://upload.wikimedia.org/wikipedia/commons/4/47/Emmanuel_Macron_-_June_2025_%283x4_cropped%29.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original CC BY 4.0 https://creativecommons.org/licenses/by/4.0 <a href="https://en.wikipedia.org/wiki/European_Commission" class="extiw" title="w:European Commission">European Commission</a>
other_probe_04.jpg File:Emmanuel Macron in 2019.jpg https://upload.wikimedia.org/wikipedia/commons/f/f4/Emmanuel_Macron_in_2019.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original Public domain <a rel="nofollow" class="external text" href="https://www.flickr.com/people/148748355@N05">The White House</a> from Washington, DC
other_probe_05.jpg File:Emmanuel Macron June 2022 (cropped).jpg https://upload.wikimedia.org/wikipedia/commons/d/d2/Emmanuel_Macron_June_2022_%28cropped%29.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=original CC BY 4.0 https://creativecommons.org/licenses/by/4.0 PRESIDENT OF UKRAINE VOLODYMYR ZELENSKYY Official website
Comment thread picmag/tests/integration_test.sh Outdated
ratzdi and others added 2 commits June 10, 2026 22:22
- debian/copyright: separate per-file license sections for
  version-RFB-320.onnx (MIT), arcfaceresnet100-8.onnx (Apache-2.0),
  retinanet-9.onnx (BSD-3-Clause), and test images (CC-BY/PD).
  Removes the incorrect blanket MIT claim for all files.
- docs/model-licenses.md: new file with upstream source references,
  per-model sha256 checksums, and redistribution notes.
- README.md: link to docs/model-licenses.md.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ratzdi ratzdi force-pushed the feature/face_detection branch from dd4f5eb to cbc9037 Compare June 18, 2026 10:09
@ratzdi ratzdi merged commit dca8d16 into master Jun 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detection & Identification

2 participants