Skip to content

Commit 05cac49

Browse files
committed
add sam3d
1 parent f5d9f06 commit 05cac49

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
@@ -1432,6 +1432,27 @@ with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
14321432
return [image_predictor, video_predictor];
14331433
};
14341434

1435+
export const sam_3d_object = (model: ModelData): string[] => [
1436+
`from inference import Inference, load_image, load_single_mask
1437+
from huggingface_hub import hf_hub_download
1438+
1439+
path = hf_hub_download("${model.id}", "pipeline.yaml")
1440+
inference = Inference(path, compile=False)
1441+
1442+
image = load_image("path_to_image.png")
1443+
mask = load_single_mask("path_to_mask.png", index=14)
1444+
1445+
output = inference(image, mask)`,
1446+
];
1447+
1448+
export const sam_3d_body = (model: ModelData): string[] => [
1449+
`from notebook.utils import setup_sam_3d_body
1450+
1451+
estimator = setup_sam_3d_body(${model.id})
1452+
outputs = estimator.process_one_image(image)
1453+
rend_img = visualize_sample_together(image, outputs, estimator.faces)`,
1454+
];
1455+
14351456
export const sampleFactory = (model: ModelData): string[] => [
14361457
`python -m sample_factory.huggingface.load_from_hub -r ${model.id} -d ./train_dir`,
14371458
];

packages/tasks/src/model-libraries.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,22 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
971971
snippets: snippets.sam2,
972972
countDownloads: `path_extension:"pt"`,
973973
},
974+
"sam-3d-object": {
975+
prettyLabel: "SAM 3D Object",
976+
repoName: "SAM 3D Object",
977+
repoUrl: "https://github.com/facebookresearch/sam-3d-objects",
978+
filter: false,
979+
snippets: snippets.sam_3d_object,
980+
countDownloads: `path:"checkpoints/pipeline.yaml"`,
981+
},
982+
"sam-3d-body": {
983+
prettyLabel: "SAM 3D Body",
984+
repoName: "SAM 3D Body",
985+
repoUrl: "https://github.com/facebookresearch/sam-3d-body",
986+
filter: false,
987+
snippets: snippets.sam_3d_body,
988+
countDownloads: `path:"model_config.yaml"`,
989+
},
974990
"sample-factory": {
975991
prettyLabel: "sample-factory",
976992
repoName: "sample-factory",

0 commit comments

Comments
 (0)