Skip to content

Commit e201d55

Browse files
authored
Add DepthPro library (#961)
1 parent f0672f9 commit e201d55

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,32 @@ depth = model.infer_image(raw_img) # HxW raw depth map in numpy
139139
];
140140
};
141141

142+
export const depth_pro = (model: ModelData): string[] => {
143+
const installSnippet = `# Download checkpoint
144+
pip install huggingface-hub
145+
huggingface-cli download --local-dir checkpoints ${model.id}`;
146+
147+
const inferenceSnippet = `import depth_pro
148+
149+
# Load model and preprocessing transform
150+
model, transform = depth_pro.create_model_and_transforms()
151+
model.eval()
152+
153+
# Load and preprocess an image.
154+
image, _, f_px = depth_pro.load_rgb("example.png")
155+
image = transform(image)
156+
157+
# Run inference.
158+
prediction = model.infer(image, f_px=f_px)
159+
160+
# Results: 1. Depth in meters
161+
depth = prediction["depth"]
162+
# Results: 2. Focal length in pixels
163+
focallength_px = prediction["focallength_px"]`;
164+
165+
return [installSnippet, inferenceSnippet];
166+
};
167+
142168
const diffusersDefaultPrompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k";
143169

144170
const diffusers_default = (model: ModelData) => [

packages/tasks/src/model-libraries.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
165165
filter: false,
166166
countDownloads: `path_extension:"pth"`,
167167
},
168+
"depth-pro": {
169+
prettyLabel: "Depth Pro",
170+
repoName: "Depth Pro",
171+
repoUrl: "https://github.com/apple/ml-depth-pro",
172+
countDownloads: `path_extension:"pt"`,
173+
snippets: snippets.depth_pro,
174+
filter: false,
175+
},
168176
diffree: {
169177
prettyLabel: "Diffree",
170178
repoName: "Diffree",

0 commit comments

Comments
 (0)