Date: 2026-08-03
Production Ready - Successfully running in production on 20,000+ files with automatic permission handling and duplicate prevention.
- Critical Bug Fixed: Nearly all images in a batch were failing with HTTP 400
exceeds the available context sizeerrors - Root Cause: Ollama's request options never set
num_ctx, so it defaulted to 4096 tokens - too small for typical image + prompt payloads (~5000+ tokens) - Solution: Added
'num_ctx': 8192to the request options inllama_inference.py - Important: Ollama fixes a model's context size at load time. If Ollama is already running with the model loaded (via
keep_alive), it must be unloaded (ollama stop qwen2.5vl:7b) or the server restarted before this fix takes effect - simply editing the code and restarting the tagger is not enough - Files:
llama_inference.py
- Discovery: The Lightroom plugin does not run the repo directly - it runs a separate copy of
llama_inference.py,racing_tagger.py,xmp_writer.py, etc. installed at%APPDATA%\Adobe\Lightroom\Modules\ - Impact: Editing files in the repo has no effect on the live plugin until those files are also copied to the Modules folder. This caused the v1.3.1 fixes (duplicate keyword prevention, permission handling, temp file cleanup) to silently never reach production, and initially masked the context-size fix above
- Action Taken: Synced
llama_inference.py,xmp_writer.py, andracing_tagger.pyfrom the repo into the Modules folder and cleared the stale__pycache__directory there - Recommendation: Any future code change intended for the live plugin must be copied to the Modules folder (or a proper install/sync script should be added) - do not assume editing the repo alone is sufficient
- Critical Bug Fixed: Running tagger multiple times on same file was creating duplicate AI Keywords
- Root Cause: Merge logic was blindly appending keywords without checking for existing AI Keywords
- Solution: Now removes all existing
AI Keywords|*entries before adding new ones - Retroactive: Works on files already tagged with older versions - simply re-run to clean up duplicates
- Testing: Verified on files tagged 6+ times, now shows clean single keyword sets
- Files:
xmp_writer.py
- New Feature: Automatic detection and fixing of read-only file permissions
- Problem: Files on NAS/network drives often set to read-only, blocking metadata writes
- Solution:
ensure_writable()function automatically makes files writable when needed - Logging: Clear visibility when permissions are changed
- Files:
xmp_writer.py
- New Feature: Automatic cleanup of leftover
_exiftool_tmpfiles - Problem: Interrupted operations (crash, Ctrl+C, permissions error) leave temp files that block future writes
- Error:
Error: Temporary file already exists: *_exiftool_tmp - Solution:
cleanup_exiftool_temp_files()function detects and removes stale temp files - Files:
xmp_writer.py
- Improvement: Changed keyword operations to use specific
XMP-dc:Subjectfield - Prevents: Cross-contamination with IPTC and other metadata groups
- Result: Cleaner, more predictable keyword management
- Files:
xmp_writer.py
- Updated: CHANGELOG.md (added v1.3.1 entry)
- Updated: README.md (added new features to Features section, new troubleshooting sections)
- Updated: CHECKPOINT.md (this file)
- ImageMagick Detection: Added automatic detection in
C:\Program Files\ImageMagick*for Windows - Image Resizing: Reduced NORMALIZE_SIZE from 2500px to 1500px to prevent GGML assertion failures
- Command Execution Fix: Fixed Lightroom plugin Windows command execution using temp batch files
- Performance: Improved from ~25s/image to ~11.5s/image on RTX 5070 Ti
- Files:
llama_inference.py,RacingTagger.lrplugin/Config.lua
- New Feature: Failed images now get error keywords written to XMP
- Error Categories:
Error:ModelCrash- GGML assertion failuresError:InferenceFailed- HTTP 500 errorsError:Timeout- Request timeoutsError:ParseError- JSON parsing failuresError:ConnectionError- Ollama connection issuesError:Unknown- Other errors
- Benefit: Easy filtering in Lightroom to identify and retry problematic images
- Files:
racing_tagger.py
- New Tool:
cleanup_old_keywords.py- One-time migration utility - Purpose: Remove old flat keywords (e.g.,
Make:Porsche,Num:73) after migrating to hierarchical structure - Preserves:
- New hierarchical keywords (
AI Keywords|Make|Porsche) - Manual keywords (track names, customer info, event names)
- New hierarchical keywords (
- Features: Dry-run mode, timestamped logging, reads/removes from both Subject and HierarchicalSubject
- Files:
cleanup_old_keywords.py(new),README.md,CHANGELOG.md
- Hardware: Ryzen 9 9950X + RTX 5070 Ti (16GB VRAM) + 128GB RAM
- Performance: 11.5s/image average in batch processing
- Comparison: Only ~2x slower than M4 Max (5.5s/image)
- Files:
README.md
- Issue: Paddock scenes with tiny/partial cars were getting hallucinated tags (e.g., pit crew photo with car sliver at edge → "Porsche 911 #202")
- Fix: Updated prompts to require car to be PRIMARY SUBJECT of image
- Result: Returns
car_detected: falsefor:- Partial cars at frame edges
- Cars <20% of frame
- Paddock/pit scenes where people are main subject
- Files:
prompts.py
- New: Cross-platform plugin (macOS + Windows)
- Location:
RacingTagger.lrplugin/ - Menu: Library → Plug-in Extras → Racing Tagger
- Tag Selected Photos
- Tag Selected Photos (Dry Run)
- Tag Folder(s)
- Tag Folder(s) (Dry Run)
- Runs tagger in background, returns to LrC immediately
- After completion: Metadata → Read Metadata from Files
- Full test on 7,509 images: 99.97% success rate
- Added no-car detection for non-car images
- Fixed badge number false positives (911, GT3, etc.)
- Benchmarked at ~6 seconds/image on M4 Max
- Gitea: http://localhost:3000/blw/LrC-classification
- GitHub: https://github.com/blwfish/LrC-classification
racing-tagger/
├── racing_tagger.py # Main CLI tool
├── cleanup_old_keywords.py # Keyword cleanup utility (one-time migration)
├── llama_inference.py # Ollama vision model integration
├── xmp_writer.py # XMP sidecar writing via exiftool
├── prompts.py # Vision prompts by profile
├── progress_tracker.py # Resume capability
├── setup.sh # Installation script (macOS/Linux)
├── RacingTagger.lrplugin/ # Lightroom Classic plugin
│ ├── Info.lua # Plugin manifest
│ ├── Config.lua # Cross-platform paths/commands
│ ├── TaggerCore.lua # Shared functionality
│ ├── TagPhotos.lua # Tag selected photos
│ ├── TagPhotosDryRun.lua
│ ├── TagFolder.lua # Tag entire folder(s)
│ └── TagFolderDryRun.lua
├── README.md
├── CHECKPOINT.md # This file
└── WINDOWS_SETUP.md # Windows installation guide
- Python 3.10+
- Ollama with
qwen2.5vl:7bmodel - exiftool (for XMP writing)
- Apple Silicon recommended (Metal acceleration)
brew install ollama exiftool- Plugin:
~/Library/Application Support/Adobe/Lightroom/Modules/
- NVIDIA GPU recommended (CUDA acceleration)
- Python in PATH
- Ollama from https://ollama.ai
- exiftool from https://exiftool.org (add to PATH)
- Plugin:
%APPDATA%\Adobe\Lightroom\Modules\
# Test single image
python3 racing_tagger.py /path/to/image.NEF --dry-run --verbose
# Process directory
python3 racing_tagger.py /path/to/images --verbose
# Resume interrupted run
python3 racing_tagger.py /path/to/images --resume --verbose
# Use larger model (slower, not necessarily better)
python3 racing_tagger.py /path/to/image.NEF --model qwen2.5vl:72b --dry-run --verbose| Metric | Value |
|---|---|
| Model | qwen2.5vl:7b (6GB) |
| Speed | ~5.5 sec/image |
| GPU | ~85% Metal |
| Memory | ~8GB during inference |
| Metric | Value |
|---|---|
| Model | qwen2.5vl:7b (6GB) |
| Speed | ~11.5 sec/image (batch average) |
| GPU | 16GB VRAM, 100% loaded |
| CPU | Ryzen 9 9950X (16-core) |
| Memory | 128GB RAM |
| ImageMagick | Required - resizes to 1500px |
- Fisheye/heavily distorted shots can confuse number detection
- Multi-car pileup shots may miss some numbers
- Very dark/backlit images have lower accuracy
- First image after cold start takes ~6s extra (model loading)