Run this model with HF Jobs

Run Petrouil/Depth-Anything-V2-Tiny-hf-quant on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/Petrouil/Depth-Anything-V2-Tiny-hf-quant. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/Petrouil/Depth-Anything-V2-Tiny-hf-quant on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Petrouil's picture
Upload folder using huggingface_hub
3039a94 verified
Raw History Blame Contribute Delete
1.3 kB
"""Minimal ONNX Runtime example for the recommended 8-layer 4-bit model."""
from __future__ import annotations
import argparse
import numpy as np
import onnxruntime as ort
from PIL import Image
MEAN = np.array([0.485, 0.456, 0.406], dtype=np.float32)
STD = np.array([0.229, 0.224, 0.225], dtype=np.float32)
def preprocess(path: str, height: int = 336, width: int = 448) -> np.ndarray:
image = Image.open(path).convert("RGB").resize(
(width, height), Image.Resampling.BICUBIC
)
x = np.asarray(image, dtype=np.float32) / 255.0
x = (x - MEAN) / STD
return x.transpose(2, 0, 1)[None].astype(np.float32)
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--image", required=True)
parser.add_argument(
"--model", default="dav2s_8layer_int4_matmul_336x448.onnx"
)
args = parser.parse_args()
session = ort.InferenceSession(
args.model, providers=["CPUExecutionProvider"]
)
input_name = session.get_inputs()[0].name
output = session.run(None, {input_name: preprocess(args.image)})[0][0]
print("inverse depth:", output.shape)
print(
"min/mean/max:",
float(output.min()),
float(output.mean()),
float(output.max()),
)
if __name__ == "__main__":
main()