Repository navigation
fix: add NumPy 2 compatibility - #629
codingbutstillalive wants to merge 7 commits into
Conversation
Restrict the supported Python version to Python 3.12 to match the currently resolvable NumPy dependency range and the validated runtime environment. Update development dependencies with known vulnerable versions: - upgrade Black from 24.2.0 to 26.3.1 - upgrade GitPython from 3.1.31 to 3.1.60 Regenerate uv.lock from the updated dependency specification. The resulting dependency set was verified with `uv audit --locked` and reports no known vulnerabilities across the resolved packages.
SAM3 imports einops from sam3.sam.rope during normal package import, so einops must be installed as a core dependency rather than only with the notebooks extra. Move einops from the notebooks optional dependency set to the project's runtime dependencies and regenerate uv.lock.
Replace the deprecated pkg_resources resource_filename API with importlib.resources. Resolve the bundled SAM3 BPE vocabulary through the current package resources API without pinning an older setuptools version. Update all three model builder code paths that resolve the default BPE vocabulary.
Move pycocotools from the development and notebook extras into the core runtime dependencies. The normal sam3 import path loads training data modules that require pycocotools, so keeping it optional makes a clean runtime installation incomplete.
Add psutil to the core runtime dependencies because the normal sam3 import path loads Sam3VideoPredictor, which uses psutil for parent-process checks. Regenerate uv.lock from the updated dependency specification.
Add a reproducible image inference test and document the BF16 autocast requirement observed with the current SAM3 image path. Verified that the video path already provides the required autocast context, while the image path fails with dtype mismatches unless image and text inference are executed under CUDA BF16 autocast.
Apply the relevant compatibility changes from upstream SAM3 PR facebookresearch#403. - relax the NumPy dependency from numpy>=1.26,<2 to numpy>=1.26 - replace deprecated np.bool aliases with np.bool_ in the panoptic visualizer - preserve the upstream SAM3 implementation otherwise unchanged The compatibility changes were validated on an NVIDIA L4 with NumPy 2.5.3, PyTorch 2.14.0+cu130, and CUDA enabled. The SAM3 Basic Usage notebook completed successfully, including image-model and video-predictor initialization.
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
Add NumPy 2 compatibility to the SAM3 fork.
Changes
numpy>=1.26,<2tonumpy>=1.26.np.boolusages withnp.bool_in the panoptic visualizer.Validation
Tested with NumPy 2.5.3:
build_sam3_image_modelsucceeds.build_sam3_video_predictorsucceeds.The changes are based on the NumPy 2 compatibility work from upstream SAM3 PR #403.