Unified Python interface for Meta SAM 3D Body and SAM 3D Objects
Project description
sam3d
sam3d 提供 SAM 3D Body 和 SAM 3D Objects 的统一 Python 接口,目标是下载好模型后可直接调用。
1. 准备模型文件
SAM 3D Body
示例路径约定:
sam-3d-body/checkpoints/sam-3d-body-dinov3/model.ckptsam-3d-body/checkpoints/sam-3d-body-dinov3/assets/mhr_model.pt
SAM 3D Objects
示例路径约定:
sam-3d-objects/checkpoints/hf/pipeline.yaml
你也可以传入自定义绝对路径(SAM3DConfig)。
2. 安装
cd /Users/sun/Projects/embody/sam3d
pip install -e .
3. 使用
import numpy as np
from sam3d import SAM3D
sam3d = SAM3D.from_defaults(
workspace_dir="/Users/sun/Projects/embody/sam3d",
device="cuda",
)
# 4.1 人体重建
body_result = sam3d.predict(
task="body",
image="/path/to/person.jpg",
)
print(len(body_result["instances"]))
# 4.2 物体重建
mask = np.zeros((1024, 1024), dtype=bool) # 你的物体 mask
obj_result = sam3d.predict(
task="objects",
image="/path/to/object.png",
mask=mask,
seed=42,
)
obj_result["gaussian_splat"].save_ply("object.ply")
4. 接口设计说明
- 统一入口:
SAM3D.predict(task=...) - 任务拆分:
predict_body(...)和predict_objects(...) - 懒加载:首次调用对应任务时才初始化模型,减少启动负担
- 与官方实现兼容:底层直接复用 Meta 仓库里的推理入口
5. 第三方源码
当前包已 vendoring 下列源码(仅包含统一接口所需部分):
sam_3d_body(来自facebookresearch/sam-3d-body)sam3d_objects(来自facebookresearch/sam-3d-objects)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sam3d-0.1.0.tar.gz
(231.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
sam3d-0.1.0-py3-none-any.whl
(304.6 kB
view details)
File details
Details for the file sam3d-0.1.0.tar.gz.
File metadata
- Download URL: sam3d-0.1.0.tar.gz
- Upload date:
- Size: 231.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57bc2dfe849c17db19e176911f458cd5390c95a2b477a5a9f81e490996ce94f5
|
|
| MD5 |
4c6a7be50ddc4328fcf20e3119baba51
|
|
| BLAKE2b-256 |
28d47d73e5e36bf6d535e84288dd6d4668f55944f6228d4669ff8bfc7ffde9f0
|
File details
Details for the file sam3d-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sam3d-0.1.0-py3-none-any.whl
- Upload date:
- Size: 304.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd233c9596f80baf4dddedc4f28ab11a12772f44e2e81df65e0bfe43eb0fdd2b
|
|
| MD5 |
91d54411188d9f8adfc64fd1a8a2ebb4
|
|
| BLAKE2b-256 |
d986e42adc5035806aa8d4618e693b9a7b03042069fc5018e2103bdd280ada26
|