-
-
Notifications
You must be signed in to change notification settings - Fork 411
Add support for local SAM 3 checkpoint #473
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
Conversation
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.
Pull request overview
This PR adds support for using a local SAM3 checkpoint file by introducing a new environment variable SAM3_CHECKPOINT_PATH. When set, this environment variable allows users (particularly QGIS Plugin users) to specify a local checkpoint path instead of downloading from HuggingFace, addressing issue #447.
- Added environment variable handling to read
SAM3_CHECKPOINT_PATHand override the checkpoint path - Added validation to ensure the specified checkpoint path exists before use
- Set
load_from_HFto False when using local checkpoints
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if os.environ.get("SAM3_CHECKPOINT_PATH") is not None: | ||
| checkpoint_path = os.environ.get("SAM3_CHECKPOINT_PATH") |
Copilot
AI
Dec 23, 2025
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.
The environment variable is retrieved twice using os.environ.get("SAM3_CHECKPOINT_PATH"). Store the result in a variable on line 203 to avoid the redundant call on line 204.
| if os.environ.get("SAM3_CHECKPOINT_PATH") is not None: | |
| checkpoint_path = os.environ.get("SAM3_CHECKPOINT_PATH") | |
| env_checkpoint_path = os.environ.get("SAM3_CHECKPOINT_PATH") | |
| if env_checkpoint_path is not None: | |
| checkpoint_path = env_checkpoint_path |
| if os.environ.get("SAM3_CHECKPOINT_PATH") is not None: | ||
| checkpoint_path = os.environ.get("SAM3_CHECKPOINT_PATH") | ||
| load_from_HF = False |
Copilot
AI
Dec 23, 2025
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.
Consider stripping whitespace from the environment variable value to handle cases where SAM3_CHECKPOINT_PATH might have leading or trailing whitespace. This would prevent unexpected errors when users accidentally include whitespace in their environment variable definition.
| if os.environ.get("SAM3_CHECKPOINT_PATH") is not None: | |
| checkpoint_path = os.environ.get("SAM3_CHECKPOINT_PATH") | |
| load_from_HF = False | |
| env_checkpoint = os.environ.get("SAM3_CHECKPOINT_PATH") | |
| if env_checkpoint is not None: | |
| env_checkpoint = env_checkpoint.strip() | |
| if env_checkpoint: | |
| checkpoint_path = env_checkpoint | |
| load_from_HF = False |
|
🚀 Deployed on https://694acb5eff4b40548d044b44--opengeos.netlify.app |
Fix opengeos/geoai#447.
Allows setting environment
SAM3_CHECKPOINT_PATHto use local SAM 3 for QGIS Plugin