Skip to content

Commit ed84e7e

Browse files
merveenoyanWauplin
andauthored
Add SAM3D libraries (#1862)
@pcuenca @ariG23498 --------- Co-authored-by: Lucain <[email protected]>
1 parent 6299707 commit ed84e7e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/tasks/src/model-libraries-snippets.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,27 @@ with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
14451445
return [image_predictor, video_predictor];
14461446
};
14471447

1448+
export const sam_3d_objects = (model: ModelData): string[] => [
1449+
`from inference import Inference, load_image, load_single_mask
1450+
from huggingface_hub import hf_hub_download
1451+
1452+
path = hf_hub_download("${model.id}", "pipeline.yaml")
1453+
inference = Inference(path, compile=False)
1454+
1455+
image = load_image("path_to_image.png")
1456+
mask = load_single_mask("path_to_mask.png", index=14)
1457+
1458+
output = inference(image, mask)`,
1459+
];
1460+
1461+
export const sam_3d_body = (model: ModelData): string[] => [
1462+
`from notebook.utils import setup_sam_3d_body
1463+
1464+
estimator = setup_sam_3d_body(${model.id})
1465+
outputs = estimator.process_one_image(image)
1466+
rend_img = visualize_sample_together(image, outputs, estimator.faces)`,
1467+
];
1468+
14481469
export const sampleFactory = (model: ModelData): string[] => [
14491470
`python -m sample_factory.huggingface.load_from_hub -r ${model.id} -d ./train_dir`,
14501471
];

packages/tasks/src/model-libraries.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,22 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
10131013
snippets: snippets.sam2,
10141014
countDownloads: `path_extension:"pt"`,
10151015
},
1016+
"sam-3d-body": {
1017+
prettyLabel: "SAM 3D Body",
1018+
repoName: "SAM 3D Body",
1019+
repoUrl: "https://github.com/facebookresearch/sam-3d-body",
1020+
filter: false,
1021+
snippets: snippets.sam_3d_body,
1022+
countDownloads: `path:"model_config.yaml"`,
1023+
},
1024+
"sam-3d-objects": {
1025+
prettyLabel: "SAM 3D Objects",
1026+
repoName: "SAM 3D Objects",
1027+
repoUrl: "https://github.com/facebookresearch/sam-3d-objects",
1028+
filter: false,
1029+
snippets: snippets.sam_3d_objects,
1030+
countDownloads: `path:"checkpoints/pipeline.yaml"`,
1031+
},
10161032
"sample-factory": {
10171033
prettyLabel: "sample-factory",
10181034
repoName: "sample-factory",

0 commit comments

Comments
 (0)