| 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} |
|
|