webnn/depth-anything-base-hf
By webnn · ↓ 0 · ♥ 0 · Updated 2025-11-20
What's in this repo
This page lists the files in webnn/depth-anything-base-hf, including model_fp16.onnx.
- 1 ONNX models (.onnx files)
- 3 files, including 1 .md, 1 .onnx
- Last updated 2025-11-20
ONNX files
| File | Size | Download |
|---|---|---|
| onnx/model_fp16.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
Xenova/depth-anything-base-hf 的 ONNX 权重,兼容 Transformers.js。
用法 (Transformers.js)
如果您还没有安装,可以从 NPM 安装 Transformers.js JavaScript 库:
npm i @huggingface/transformers
示例: 使用 Xenova/depth-anything-base-hf 进行深度估计。
import { pipeline } from '@huggingface/transformers';
// 创建深度估计流水线
const depth_estimator = await pipeline('depth-estimation', 'Xenova/depth-anything-base-hf');
// 对给定图像预测深度图
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/bread_small.png';
const output = await depth_estimator(url);
// {
// predicted_depth: Tensor {
// dims: [350, 518],
// type: 'float32',
// data: Float32Array(181300) [...],
// size: 181300
// },
// depth: RawImage {
// data: Uint8Array(271360) [...],
// width: 640,
// height: 424,
// channels: 1
// }
// }
您可以使用以下代码可视化输出:
output.depth.save('depth.png');
注意:为 ONNX 权重创建单独的仓库是一个临时方案,直到 WebML 获得更多关注。如果您想让您的模型支持 Web,我们建议使用 🤗 Optimum 转换为 ONNX 格式,并按照此仓库的结构组织(将 ONNX 权重放在名为 onnx 的子文件夹中)。
将 fp16 模型中 Pow X Y 的数据类型从 float16 更改为 float32。
Model info
Created: 2025-11-20
Updated: 2025-11-20
View on Hugging Face