Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/tasks/src/model-libraries-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
];
Expand Down
16 changes: 16 additions & 0 deletions packages/tasks/src/model-libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"`,
},
Comment on lines +974 to +989
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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"`,
},
"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"`,
},
"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"`,
},

(nit) to keep alphabetical order

"sample-factory": {
prettyLabel: "sample-factory",
repoName: "sample-factory",
Expand Down
Loading