-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: Add additional env variables for Machine Learning #15326
base: main
Are you sure you want to change the base?
Conversation
📖 Documentation deployed to pr-15326.preview.immich.app |
machine-learning/app/config.py
Outdated
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
from rich.console import Console | ||
from rich.logging import RichHandler | ||
from uvicorn import Server | ||
from uvicorn.workers import UvicornWorker | ||
|
||
|
||
class ClipSettings(BaseModel): | ||
model: str | None = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking - this interface assumes the same model name will be used for all parts of a task. This is currently true, but might not hold in the future. I think the other approach of doing MACHINE_LEARNING_PRELOAD__CLIP__TEXTUAL=<model name>
etc., while more verbose, will be more future-proof so we don't need to make another breaking change down the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a fair point. Instead of 3 env variables per model, shall I drop it down to two strings instead of a string and 2 booleans?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me!
@@ -76,19 +76,32 @@ async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]: | |||
|
|||
async def preload_models(preload: PreloadModelData) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add deprecation warnings for the old envs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how I'd go about that, just as a comment or something more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check if the fallback env is not None
and call log.warn
saying it's deprecated and you should use X instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, thanks much!
Add additional variables to only preload partial models.
MACHINE_LEARNING_PRELOAD__CLIP
has been depreciated and replaced withMACHINE_LEARNING_PRELOAD__CLIP__MODEL
MACHINE_LEARNING_PRELOAD__FACIAL_RECOGNITION
has been depreciated and replaced withMACHINE_LEARNING_PRELOAD__FACIAL_RECOGNITION__MODEL