File size: 533 Bytes
2d2cf07 6180f08 2d2cf07 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from depth_anything_3.api import DepthAnything3
import torch, base64, io
from PIL import Image
import numpy as np
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = DepthAnything3.from_pretrained("APaul1/DA3METRIC-LARGE").to(device)
def predict(payload):
img_bytes = base64.b64decode(payload["image"])
img = Image.open(io.BytesIO(img_bytes)).convert("RGB")
pred = model.inference([img], export_dir=None, export_format="npz")
depth = pred[0]["depth"].tolist()
return {"depth": depth}
|