Commit Graph
39 Commits
Author SHA1 Message Date
Horatiu George TodoranandCodex f418967d55 perf: RKNN half RAM model usage + no weight duplication in multi-core (#23958)
* perf(ml): share RKNN weights across NPU cores and halve model RAM

* perf(ml): default rknn threads to npu cores and cache shape setup

* perf(ml): serve rknn runs in arrival order

(cherry picked from commit e659fb62f2bb3f6b1db08ed643d3d054a539c415)
2026-10-28 20:40:53 +03:00
MertandCodex db411a4497 feat(server): add jxl as target format (#32732)
(cherry picked from commit 9560989cb97fb93cd6ab74f7811acce133a9b768)
2026-10-27 23:12:52 +03:00
YarosandCodex 3f3671fbe5 fix(ml): preloaded model loaded twice (#32610)
fix(ml): reuse cached model across names that clean to the same model

(cherry picked from commit 166e93559f123313cf9cb4e7324c4ee30e21c618)
2026-10-22 05:23:22 +03:00
8ebb3ef4ec feat(ml): ppocr v6 (#32151)
feat(ml): ppocr v6 (#32147)

(cherry picked from commit 3df38fe7f283391819482b41a7181edc3f923d1f)

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
2026-10-06 08:44:13 +00:00
2bb3d0807f fix(ml): upgrade to openvino 2026.4.1 (#32020)
fix(ml): upgrade to openvino 2026.4.1 (#31996)

(cherry picked from commit 524cbb31674ab825d0883076e83d200a341aa516)

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
2026-10-02 16:41:49 +02:00
d2136aae98 fix(ml): widen empty half-precision arrays (#31962)
fix(ml): widen empty half-precision arrays (#31950)

(cherry picked from commit b11e400a36a40fd588364ebf31fd671f97cdf446)

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
2026-09-30 23:09:03 +00:00
a506c8a28f fix(ml): serialize trt-rtx sessions (#31963)
fix(ml): serialize trt-rtx sessions (#31951)

(cherry picked from commit a3c8b359f2fdc47699f1530215a23fe8bd34c454)

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
2026-09-30 23:08:58 +00:00
MertandGitHub 76c239c345 feat(ml): trt-rtx (#31863)
* trt-rtx

* update dependencies
2026-09-28 21:39:14 +00:00
MertandGitHub ab159b8118 fix(ml): stricter typing and request validation (#31856) 2026-09-28 14:14:01 -04:00
MertandGitHub 23f1f87dd0 feat(ml): optimized model inference (#31750)
* add immich_model

* graph per shape

* decouple ocr from ort

* prepared graphs

* use f16 for accelerators

* preload all shapes

* warm-up pass after preload

* keep precision for fp32 graphs

* ensure padding for text recognition

* optimize postprocessing for fp16 outputs

* handle raw ctc logits

* use f16 output for rknn

* mmap token embedding

* read device metadata
2026-09-25 14:56:44 -04:00
MertandGitHub de13aab713 feat(ml): improve model loading (#31742)
* use recent mimalloc

* jit caching

* bump onnxruntime-gpu

* explicit memory release

* refactor in-memory cache

* configure hf org and revision

* refactor model load

* move orjson response

* disable direct submission for i915

* flush denormals

* update tests and lock

* disable suboptimal fusions

* respect resize_mode

* increase threads for clip text
2026-09-25 14:56:43 -04:00
WenbinandGitHub 26a25f0c3a fix(ml): race when submitting to rknn execution queue (#31143) 2026-09-03 02:13:35 +00:00
Aditya Raj SinghandGitHub c1a88dd9a3 fix(ml): read CLIP model configs as UTF-8 (#31075) 2026-08-27 23:04:40 -04:00
MertandGitHub dc688edb6f refactor(ml): direct ocr processing (#31016) 2026-08-25 23:13:47 -04:00
MertandGitHub 79e61c47c7 refactor(ml): remove insightface dependency (#30631)
* remove insightface dependency

* update tests
2026-08-08 12:07:30 -04:00
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>mertalev
408e1180ca chore(deps): update machine-learning (#28239)
* chore(deps): update machine-learning

* fix typing

* fix deprecation log

* no control socket

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
2026-06-02 16:44:50 +00:00
pneulyandGitHub a838167f11 fix(ml): pass model_root_dir to OcrOptions for RapidOCR compatibility (#28610)
* fix(ml): pass model_root_dir to OcrOptions for RapidOCR compatibility

Fix a TypeError (Path(None)) when the OCR model is invoked, caused by an upstream change in RapidOCR v3.8.1 (RapidAI/RapidOCR@8ea9626).
RapidOCR now internally calls `Path(cfg.get("model_root_dir"))`. Since `model_root_dir` was missing from `OcrOptions`, it evaluated to `None` and triggered a `TypeError: argument should be a str or an os.PathLike`.
This fix adds the missing `model_root_dir` argument to prevent the error.
Ref: #28331

* fix(ml-test): update OCR tests for RapidOCR schema change

* chore(ml-test): remove unused `cache_dir` parameter from `TextRecognizer`

* Revert "chore(ml-test): remove unused `cache_dir` parameter from `TextRecognizer`"

This reverts commit 007ad7b3f22b0c93cfc237509b460eb6d5c51075.

* fix(ml): use self.cache_dir for model_root_dir in OcrOptions
2026-05-28 22:54:04 -04:00
Fabian WimbergerandGitHub 53a24783f5 fix(ml): stabilize MIGraphX inference (#28444)
* fix: stabilize ROCm MIGraphX inference

Serialize MIGraphX session runs so lazy compiles cannot overlap within a worker.

Use a fixed face-recognition batch size for MIGraphX to avoid compiling a new program for each detected face count.

* fix(ml): increase ROCm worker timeout

* fix(ml): narrow MIGraphX compile locking

* docs: format environment variables table

* docs: apply prettier to environment variables table
2026-05-26 18:41:56 +00:00
MertandGitHub 8c8dc9d32f chore(ml)!: remove deprecated envs (#28326)
remove deprecated envs
2026-05-09 22:40:05 +00:00
5e89efba64 fix(ml): handle empty/corrupt images in face detection (#27391)
* fix(ml): handle empty/corrupt images in face detection

When a corrupt or degenerate image with zero-dimension (0 width or 0 height)
reaches the face detection pipeline, insightface's RetinaFace.detect() calls
cv2.resize() with a target size of 0, triggering an OpenCV assertion failure:

  error: (-215:Assertion failed) inv_scale_x > 0 in function 'resize'

This crashes the ML worker and returns a 500 error to the server.

Add an early return in FaceDetector._predict() that checks for zero-dimension
images after decoding and returns empty detection results instead of passing
them to the insightface model.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ml): move empty image validation to request level

Per review feedback, validate image dimensions in the predict endpoint
(returning 400) rather than in each model's _predict method. This
catches all zero-dimension images before they reach any model task.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ml): resolve mypy strict type error in predict endpoint

Use intermediate `decoded` variable so mypy knows `.width` and `.height`
are accessed on `Image`, not on `Image | str`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 11:14:34 -04:00
aaf34fa7d4 feat(ml): enable openvino for cpu (#22948)
* Enable OpenVINO CPU acceleration in Immich

* Remove unnecessary debug log

* Removing checking for device_ids for openvino since cpu will always be available

* Find OpenVINOExecutionProvider index instead of assuming index 0

* Fix openvino tests

* Fix failing test mock. OpenVINO expects provider options, but cuda provide doesn't so use that for mocked tests.

* Support empty provider options in OrtSessions in which case ONNXRuntime will use its own defaults

* Use OpenVINOExecutionProvider for test_sets_provider_options_kwarg

* fix mock

* simplify

* unused variable

---------

Co-authored-by: Aleksander <pejcic@adobe.com>
Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
2026-03-07 18:40:43 +00:00
MertandGitHub 35a521c6ec fix(ml): batch size setting (#26524) 2026-03-05 12:01:47 -05:00
Kishor PrinsandGitHub dd9046508d feat: ROCm 7.2 and MIGraphX support (#26178) 2026-02-26 16:52:26 +00:00
Savely KrasovskyandGitHub 3321c1a9df feat(ml): update ONNX Runtime, OpenVINO and ROCm stack (#23458) 2026-01-01 12:17:55 -05:00
MertandGitHub 6249996cdb fix(ml): do not upscale preview (#24322)
do not upscale
2025-12-01 20:26:01 -06:00
Alexander SulfrianandGitHub 5186092faa fix: Update module name for rapidocr DownloadFile (#23838) 2025-11-12 18:43:00 +00:00
MertandGitHub 6913697ad1 feat(ml): multilingual ocr (#23527)
* handle other languages in ml server

* add variants to model selector

* no need to override path

* unused import
2025-11-06 12:58:41 -05:00
MertandGitHub a4ae86ce29 feat(ml): add preload and fp16 settings for ocr (#23576) 2025-11-06 17:55:11 +00:00
MertandGitHub 79d0e3e1ed fix(ml): ocr inputs not resized correctly (#23541)
* fix resizing, use pillow

* unused import

* linting

* lanczos

* optimizations

fused operations

unused import
2025-11-03 07:21:30 +00:00
MertandGitHub 4abaad548a fix(ml): ocr failing with rootless docker (#23402)
don't download font
2025-10-31 02:41:49 -04:00
02b29046b3 feat: ocr (#18836)
* feat: add OCR functionality and related configurations

* chore: update labeler configuration for machine learning files

* feat(i18n): enhance OCR model descriptions and add orientation classification and unwarping features

* chore: update Dockerfile to include ccache for improved build performance

* feat(ocr): enhance OCR model configuration with orientation classification and unwarping options, update PaddleOCR integration, and improve response structure

* refactor(ocr): remove OCR_CLEANUP job from enum and type definitions

* refactor(ocr): remove obsolete OCR entity and migration files, and update asset job status and schema to accommodate new OCR table structure

* refactor(ocr): update OCR schema and response structure to use individual coordinates instead of bounding box, and adjust related service and repository files

* feat: enhance OCR configuration and functionality

- Updated OCR settings to include minimum detection box score, minimum detection score, and minimum recognition score.
- Refactored PaddleOCRecognizer to utilize new scoring parameters.
- Introduced new database tables for asset OCR data and search functionality.
- Modified related services and repositories to support the new OCR features.
- Updated translations for improved clarity in settings UI.

* sql changes

* use rapidocr

* change dto

* update web

* update lock

* update api

* store positions as normalized floats

* match column order in db

* update admin ui settings descriptions

fix max resolution key

set min threshold to 0.1

fix bind

* apply config correctly, adjust defaults

* unnecessary model type

* unnecessary sources

* fix(ocr): switch RapidOCR lang type from LangDet to LangRec

* fix(ocr): expose lang_type (LangRec.CH) and font_path on OcrOptions for RapidOCR

* fix(ocr): make OCR text search case- and accent-insensitive using ILIKE + unaccent

* fix(ocr): add OCR search fields

* fix: Add OCR database migration and update ML prediction logic.

* trigrams are already case insensitive

* add tests

* format

* update migrations

* wrong uuid function

* linting

* maybe fix medium tests

* formatting

* fix weblate check

* openapi

* sql

* minor fixes

* maybe fix medium tests part 2

* passing medium tests

* format web

* readd sql

* format dart

* disabled in e2e

* chore: translation ordering

---------

Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2025-10-27 14:09:55 +00:00
MertandGitHub 1b62c2ef55 feat(ml): coreml (#17718)
* coreml

* add test

* use arena by default in native installation

* fix tests

* add env to docs

* remove availability envs
2025-10-14 17:51:31 +00:00
MertandGitHub 5270107926 fix(ml): ipv6 check (#22735) 2025-10-07 12:24:23 -04:00
CokodayoandGitHub 51150a3ed1 fix(ml): Resolve IPv6 startup crash and healthcheck failure (#22387)
* fix(ml): Resolve IPv6 startup crash and healthcheck failure

Fixes #13782

* fix(ml): updated the fix to use the std lib

* Apply code formatting to __main__.py
2025-10-06 12:09:40 -04:00
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>mertalev
adb55f3726 fix(deps): update machine-learning (#19803)
* fix(deps): update machine-learning

* typing fixes

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
2025-08-11 18:07:49 -04:00
Matthew MomjianandGitHub d233a7d97a fix(server): remove excessive inactivity log (#19306) 2025-06-19 19:13:13 +00:00
luzpazandGitHub b1e1362246 fix: various typos (grouped in to separate commits) (#18177) 2025-05-09 13:10:34 +00:00
MertandGitHub 6789c2ac19 feat(ml): better multilingual search with nllb models (#13567) 2025-03-31 11:06:57 -04:00
MertandGitHub 84c35e35d6 chore(ml): installable package (#17153)
* app -> immich_ml

* fix test ci

* omit file name

* add new line

* add new line
2025-03-27 19:49:09 +00:00