Repository navigation
feat(ml)!: switch image classification and CLIP models to ONNX - #3809
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
|
Hello, for people for existing model_cache volume, I assume it will download the new models and use the new model to run, correct? |
|
Yup, it'll download a model if it doesn't see it in the cache, so the model cache doesn't need any user intervention. But the old models will still be there until they're deleted by the user. |
|
Great job! I'm wondering if this would be better that users can manually configure the expected size of the CLIP model output dimensions listed here, as some may want to use a different one, such as M-CLIP/XLM-Roberta-Large-Vit-L-14 with 768 output dimensions. Here are some codes that may be related. immich/machine-learning/app/test_main.py Line 75 in 165b91b |
|
Thanks! I'm planning on moving the ML settings to the admin page so they're stored in the server and sent as part of the request. That way, the server can know what embedding size it should set instead of hardcoding it. |
|
Although, to some extent that specific variable might require some more work. There are other places where the length is specifically set, like in the typesense schema, it has a hardcoded length of 512 |
|
Yeah, I think I'd have to update the asset schema to use the new embedding size and drop the current embeddings. (And give a pop-up warning about this beforehand). Hmm maybe it'd be better to do this after switching away from Typesense since I'd have to rewrite this logic for pgvector. |
|
Yeah. I think we can get all the rest of the options configurable pretty easily though, so we can definitely start there. |
|
Isn't |
|
clip-server is installed separately in the Dockerfile with the |
Description
While facial recognition already used ONNX models, this change brings them over to other ML tasks as well. There are a number of important advantages with this change:
NOTE: There's a breaking change in this PR. Since Sentence-Transformers is no longer used for CLIP models, users who set
MACHINE_LEARNING_CLIP_IMAGE_MODELorMACHINE_LEARNING_CLIP_TEXT_MODELmust migrate to one of the ViT-B models listed here, with the caveat that OpenCLIP models will require running CLIP on all images since the embeddings are incompatible.How Has This Been Tested?
I deleted the model cache volume and started the server to confirm that it downloaded each model on startup without error. After the ML service completed startup, I started jobs for object tagging, CLIP and facial recognition and observed no errors. Performance is higher than on main while RAM consumption is about equal.
Edit: I did some load-testing with Locust for more formal results. ML on this branch is over 3.5x faster compared to main.
Likewise, latency is much lower as well.