Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ml): model downloading #3545

Merged
merged 16 commits into from
Aug 6, 2023
Merged

refactor(ml): model downloading #3545

merged 16 commits into from
Aug 6, 2023

Conversation

mertalev
Copy link
Contributor

@mertalev mertalev commented Aug 4, 2023

Description

This PR distinguishes between downloading and loading models. Specifically, it adds a new download method that can be used independently from the load method for each model type.

There are several useful benefits to this:

  • Lazy loading of models without compromising on the ability to download models at startup
  • Simplified startup logic
    • Model classes can be instantiated freely since they can handle eager/lazy loading internally
  • Faster startup times
    • Insightface's logic for loading models is very inefficient: it loads every model in the folder and inspects their inputs and outputs, then unloads the ones that aren't relevant.
    • The new implementation only loads relevant models, and in fact only extracts these models from the zip file on download.

How Has This Been Tested?

  • No errors on startup
  • Deleting the model cache and restarting downloads each model once
  • After restarting the container, it does not download any models
  • Object tagging, CLIP and facial recognition jobs run as normal

@vercel
Copy link

vercel bot commented Aug 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Aug 5, 2023 10:25pm

@mertalev
Copy link
Contributor Author

mertalev commented Aug 4, 2023

I should probably update the tests...

@mertalev mertalev marked this pull request as draft August 4, 2023 07:17
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@mertalev mertalev marked this pull request as ready for review August 5, 2023 22:28
@alextran1502 alextran1502 merged commit c73832b into main Aug 6, 2023
21 checks passed
@alextran1502 alextran1502 deleted the chore/ml-download-models branch August 6, 2023 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants