PhotoMapperAI maps external player photos to internal player records and generates portrait crops. The repository contains:
- a CLI for automation and batch workflows
- an Avalonia desktop UI for step-by-step and batch usage
- supporting docs, validation scripts, and SQL/query templates
Typical workflow:
extractexports players or teams from your database into CSV.maplinks photos to CSV rows using direct ID matches, deterministic name matching, and optional AI fallback.generatephotoscreates portraits from the mapped CSV with configurable face detection and output sizing.benchmarkandbenchmark-comparehelp compare model behavior and regression results.
The CLI entry point is photomapperai and exposes these subcommands:
extractmapgeneratephotosbenchmarkbenchmark-compare
Examples:
dotnet run --project src/PhotoMapperAI -- extract \
--inputSqlPath samples/sql-examples/sql-server-players.sql \
--connectionStringPath samples/connection_string_template.txt \
--teamId 10 \
--outputName team.csv
dotnet run --project src/PhotoMapperAI -- map \
--inputCsvPath team.csv \
--photosDir ./photos \
--useAI \
--aiSecondPass \
--nameModel qwen2.5:7b
dotnet run --project src/PhotoMapperAI -- generatephotos \
--inputCsvPath team.csv \
--photosDir ./photos \
--processedPhotosOutputPath ./portraits \
--format jpg \
--faceDetection opencv-yunet- Direct ID matches are applied first when
External_Player_IDalready exists. - Deterministic matching runs globally for unresolved rows before any AI calls.
- AI is optional and can run as fallback with
--useAI,--aiSecondPass, or--aiOnly. - Provider-aware model identifiers are supported, including local and cloud-backed variants such as:
qwen2.5:7bollama:qwen2.5:7bopenai:gpt-5-minianthropic:claude-3-5-sonnetzai:glm-4.5minimax:MiniMax-M2.5
See docs/guides/NAME_MAPPING_PIPELINE.md for the current mapping logic and tuning notes.
- Face detection models currently wired in code include:
apple-visionopencv-yunetopencv-dnnyolov8-facehaar-cascadecenter- Ollama vision models such as
llava:7bandqwen3-vl
- Fallback chains are supported through comma-separated values, for example:
opencv-yunet,llava:7b,center
- Size profiles are supported through
--sizeProfileand--allSizes. - Output profile aliases are supported through
--outputProfilewithnone,test, andprod. - Crop-frame overrides are supported through
--cropFrameWidthand--cropFrameHeight. - Placeholder handling is supported through
--placeholderImageor per-variantplaceholderPathin a size profile. - Single-player verification runs are supported through
--onlyPlayer.
See docs/guides/FACE_DETECTION_GUIDE.md for the current generate flow.
Run the UI with:
dotnet run --project src/PhotoMapperAI.UI/PhotoMapperAI.UI.csprojCurrent UI capabilities:
- step-by-step Extract, Map, and Generate workflow
- batch automation for multi-team processing
- preview generation with the shared generation logic
- custom preview crop-frame presets
- session save/load to the default app-data location
- manual unmapped-player repair dialog in map and batch flows
- face-detection defaults that are platform-aware
- macOS prefers
apple-vision - Windows/Linux prefer
opencv-yunet
- macOS prefers
See docs/guides/GUIDE.md.
Relevant root-level files:
appsettings.template.json: template for OpenCV paths, Ollama defaults, preview presets, and output profilessize_profiles.json: sample multi-size generation profiletest-config.template.json: template for local-only validation data layout
Notes:
- the UI project copies
size_profiles.jsonandappsettings.jsoninto its output - OpenCV download URLs and model filenames are defined in
appsettings.json - output profile aliases can be sourced from config and overridden by environment variables where supported by the resolver
Build:
dotnet build PhotoMapperAI.slnRun tests:
dotnet test tests/PhotoMapperAI.Tests/PhotoMapperAI.Tests.csprojUseful scripts:
scripts/run_external_validation.pyscripts/run_validation_suite.pyscripts/compare_portrait_sets.pyscripts/download-opencv-models.ps1scripts/download-opencv-models.sh
src/PhotoMapperAI CLI and core services
src/PhotoMapperAI.UI Avalonia desktop UI
tests/PhotoMapperAI.Tests Unit tests
docs/ Guides, testing notes, reports, planning docs
samples/ SQL and config templates
scripts/ Validation and operational helpers
docs/README.md: documentation indexCHANGELOG.md: release history and unreleased changesRELEASE_NOTES.md: release draft notes