{"id":50480944,"url":"https://github.com/derekslinz/photoram","last_synced_at":"2026-06-01T17:30:41.104Z","repository":{"id":337881846,"uuid":"1155618364","full_name":"derekslinz/photoram","owner":"derekslinz","description":"Modern CLI photo tagger powered by RAM++. Command-line image tagger that uses RAM++ (Recognize Anything Model) to generate high-quality English tags with optional confidence scores, batch inference, and metadata writing (EXIF/XMP/IPTC). Stable JSON output contract (always a list), flexible device selection (cpu/cuda/mps) and darktable script.","archived":false,"fork":false,"pushed_at":"2026-02-23T09:51:08.000Z","size":743,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-23T18:16:50.389Z","etag":null,"topics":["computer-vision","darktable","darktable-plugin","imagetagging"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derekslinz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-11T17:59:21.000Z","updated_at":"2026-02-23T09:51:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/derekslinz/photoram","commit_stats":null,"previous_names":["derekslinz/photoram"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/derekslinz/photoram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derekslinz%2Fphotoram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derekslinz%2Fphotoram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derekslinz%2Fphotoram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derekslinz%2Fphotoram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derekslinz","download_url":"https://codeload.github.com/derekslinz/photoram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derekslinz%2Fphotoram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33786895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","darktable","darktable-plugin","imagetagging"],"created_at":"2026-06-01T17:30:36.742Z","updated_at":"2026-06-01T17:30:41.094Z","avatar_url":"https://github.com/derekslinz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# photoram\n\n`photoram` is a CLI photo classifier powered by ImageNet-21K. It is designed as a modern, scriptable successor to [photils-cli](https://github.com/scheckmedia/photils-cli). The installed command is `photoram-cli`.\n\n## Highlights\n\n- ImageNet-21K classification with 21k-class label space.\n- Offline inference after first-run model download.\n- Batch inference (`--batch-size`) with streaming mini-batch loading.\n- Stable JSON output contract: `--format json` always returns a list.\n- Standardized exit codes and validation errors.\n- Service-layer architecture (`TaggingService`) that decouples CLI from model internals.\n- photils compatibility flags: `--image`, `--output_file`, `--with_confidence`.\n\n## Security Hardening\n\n- Deterministic model selection: pinned default model id (`vit_base_patch16_224.augreg_in21k`).\n- Image safety checks: decompression-bomb protection is enabled (`PHOTORAM_MAX_IMAGE_PIXELS`, default `120000000`).\n- Metadata subprocess hardening: exiftool invocation uses `--` before image path to prevent option parsing.\n- Streaming batch loader: avoids preloading all tensors for large jobs.\n- CI security gates: `bandit` (SAST) and `pip-audit` (dependency CVEs).\n\n## Requirements\n\n- Python 3.9+\n- `pip`\n- `git` (for source installs)\n\n## Installation\n\n### Local editable install\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\npython -m pip install --upgrade pip\npip install -e .\nphotoram-cli --help\n```\n\n### Reproducible install (constraints)\n\n```bash\npip install -c constraints.txt -e .\n```\n\n### Optional extras\n\n```bash\n# Metadata fallback support (pyexiv2)\npip install -e \".[metadata]\"\n\n# Dev + test + security tooling\npip install -c constraints.txt -e \".[dev]\"\n```\n\nIf you use `--write-metadata`, installing `exiftool` is recommended:\n\n```bash\n# macOS\nbrew install exiftool\n\n# Debian/Ubuntu\nsudo apt install libimage-exiftool-perl\n```\n\n## Quick Start\n\n```bash\n# Tag one image\nphotoram-cli tag photo.jpg\n\n# Include confidence scores\nphotoram-cli tag photo.jpg --confidence\n\n# Recursive directory tagging\nphotoram-cli tag ./photos --recursive\n\n# Batch inference (faster on GPU, higher VRAM use)\nphotoram-cli tag ./photos --recursive --batch-size 32\n\n# Write metadata\nphotoram-cli tag photo.jpg --write-metadata\n\n# JSON output (always a list)\nphotoram-cli tag photo.jpg --format json\n\n# Print timing summary (model load, tagging, total)\nphotoram-cli tag photo.jpg -T\n\n# Show environment/model cache info\nphotoram-cli info\n```\n\nNote: first run requires internet access to download the ImageNet-21K model into the Hugging Face cache.\n\n## Commands\n\n### `photoram-cli tag`\n\n```text\nphotoram-cli tag [OPTIONS] INPUT...\n\nArguments:\n  INPUT                  Image file(s) or directory to tag\n\nOptions:\n  -t, --threshold FLOAT  Minimum class probability 0.0-1.0 (default: 0.0)\n  -n, --top-n INTEGER    Maximum number of tags to return\n  -c, --confidence       Show confidence scores\n  -f, --format FORMAT    Output format: text, json, csv (default: json)\n  -o, --output FILE      Write results to file\n  -r, --recursive        Recursively scan directories\n  -w, --write-metadata   Write tags to image EXIF/XMP/IPTC metadata\n      --overrides FILE   Tag override/translation JSON file\n      --batch-size INT   Images per inference batch (default: 16)\n  -T, --timings          Print basic timings (load, tagging, total)\n  -q, --quiet            Suppress progress output\n  -h, --help             Show help\n```\n\nCompatibility alias for photils-dt-style calls:\n\n```bash\nphotoram-cli tag --image \"$FILE\"\n```\n\n### `photoram-cli info`\n\nPrints package version, torch/runtime capability, resolved default device, and model cache information.\n\n## darktable Lua Plugin\n\nA multi-image darktable plugin is included at:\n\n- `darktable/photoram.lua`\n\nWhat it does:\n\n- Works on all selected images in one action (not single-image only).\n- Exposes tunable parameters in darktable preferences:\n- `photoram: executable` -\u003e command/path to `photoram-cli`\n- `photoram: max tags` -\u003e `--top-n`\n- `photoram: threshold (%)` -\u003e `--threshold`\n- `photoram: batch size` -\u003e `--batch-size`\n- `photoram: write metadata` -\u003e `--write-metadata`\n- `photoram: quiet output` -\u003e `--quiet`\n- `photoram: show timings` -\u003e `--timings`\n- `photoram: device` -\u003e `--device`\n- `photoram: overrides file` -\u003e `--overrides`\n\nInstall:\n\n```bash\nmkdir -p ~/.config/darktable/lua\ncp darktable/photoram.lua ~/.config/darktable/lua/photoram.lua\necho 'require \"photoram\"' \u003e\u003e ~/.config/darktable/luarc\n```\n\nThen restart darktable and run the selected-images action:\n\n- `photoram auto-tag`\n\nThe plugin also registers a visible panel module:\n\n- Name: `photoram auto-tagger`\n- Location: right panel in lighttable (or left panel in darkroom)\n- Button: `auto-tag selected`\n\nTroubleshooting:\n\n1. Check darktable Lua logs for load errors:\n- Linux/macOS: start darktable from terminal and inspect stderr output.\n2. Ensure the panel is enabled in darktable module visibility settings.\n3. Confirm plugin is in the exact path:\n- `~/.config/darktable/lua/photoram.lua`\n4. Confirm `luarc` contains:\n- `require \"photoram\"`\n5. If `photoram-cli` is not on PATH, set preference:\n- `photoram: executable` to full binary path (for example `/usr/local/bin/photoram-cli`).\n\n## Output Contract\n\n### JSON (`--format json`)\n\nAlways returns a list, even for one image.\n\n```json\n[\n  {\n    \"file\": \"photo.jpg\",\n    \"tags\": [\"tree\", \"sky\"]\n  }\n]\n```\n\n- Add `--confidence` to include `confidences`.\n- Failed files include an `error` field.\n\n### Text (`--format text`)\n\n- One image: `tag1 | tag2 | tag3`\n- Multiple images: `\u003cfile\u003e\\t\u003ctags\u003e` per line\n\n### CSV (`--format csv`)\n\n- Base columns: `file`, `tags`\n- Optional columns: `confidences`\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| 0 | Success |\n| 1 | No images found |\n| 2 | Invalid arguments |\n| 3 | Model/download/load error |\n| 4 | Other runtime error |\n\n## Tag Overrides\n\nCreate `override_labels.json`:\n\n```json\n{\n  \"blackbackground\": \"black background\",\n  \"art\": \"kunst\",\n  \"shadow\": \"schatten\"\n}\n```\n\nLookup order:\n\n- Explicit `--overrides \u003cfile\u003e`\n- `~/.config/photoram/override_labels.json`\n\n## Architecture\n\n```text\ncli.py -\u003e service.py -\u003e model.py\n                 \\-\u003e utils.py\n                 \\-\u003e schemas.py\n                 \\-\u003e errors.py\n                 \\-\u003e metadata.py\n```\n\n- `src/photoram/cli.py`: Click commands, progress, output and exit handling.\n- `src/photoram/service.py`: orchestration layer (collection, dispatch, post-processing).\n- `src/photoram/model.py`: ImageNet-21K model loading, preprocessing, inference, safety checks.\n- `src/photoram/schemas.py`: result schemas (`TagResult`, `BatchResult`).\n- `src/photoram/errors.py`: exception hierarchy and exit codes.\n- `src/photoram/metadata.py`: metadata writing adapters.\n- `src/photoram/utils.py`: file discovery, overrides, format helpers.\n\n## Development and Tests\n\n```bash\npip install -c constraints.txt -e \".[dev]\"\npytest\n```\n\nSecurity scans:\n\n```bash\nbandit -q -r src\npip-audit\n```\n\nMain CLI contract tests:\n\n- `tests/test_cli.py`\n- `tests/test_cli_integration.py`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderekslinz%2Fphotoram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderekslinz%2Fphotoram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderekslinz%2Fphotoram/lists"}