diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index e03256f7d3..d982e8e721 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -1432,6 +1432,27 @@ with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): return [image_predictor, video_predictor]; }; +export const sam_3d_object = (model: ModelData): string[] => [ + `from inference import Inference, load_image, load_single_mask +from huggingface_hub import hf_hub_download + +path = hf_hub_download("${model.id}", "pipeline.yaml") +inference = Inference(path, compile=False) + +image = load_image("path_to_image.png") +mask = load_single_mask("path_to_mask.png", index=14) + +output = inference(image, mask)`, +]; + +export const sam_3d_body = (model: ModelData): string[] => [ + `from notebook.utils import setup_sam_3d_body + +estimator = setup_sam_3d_body(${model.id}) +outputs = estimator.process_one_image(image) +rend_img = visualize_sample_together(image, outputs, estimator.faces)`, +]; + export const sampleFactory = (model: ModelData): string[] => [ `python -m sample_factory.huggingface.load_from_hub -r ${model.id} -d ./train_dir`, ]; diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index 16ec332a2a..a3dd53bbdd 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -971,6 +971,22 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { snippets: snippets.sam2, countDownloads: `path_extension:"pt"`, }, + "sam-3d-object": { + prettyLabel: "SAM 3D Object", + repoName: "SAM 3D Object", + repoUrl: "https://github.com/facebookresearch/sam-3d-objects", + filter: false, + snippets: snippets.sam_3d_object, + countDownloads: `path:"checkpoints/pipeline.yaml"`, + }, + "sam-3d-body": { + prettyLabel: "SAM 3D Body", + repoName: "SAM 3D Body", + repoUrl: "https://github.com/facebookresearch/sam-3d-body", + filter: false, + snippets: snippets.sam_3d_body, + countDownloads: `path:"model_config.yaml"`, + }, "sample-factory": { prettyLabel: "sample-factory", repoName: "sample-factory",