metadata
license: apache-2.0
This is the Offical weights of ConFiDeNet
from PIL import Image
import torch
from transformers import ConFiDeNetForDepthEstimation, ConFiDeNetImageProcessor
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
image = Image.open("<Image Path>").convert("RGB")
print(image.size)
# image.save("image.jpg")
image_processor = ConFiDeNetImageProcessor.from_pretrained("<Weight-Path>")
model = ConFiDeNetForDepthEstimation.from_pretrained("<Weigh-Path>").to(device)
inputs = image_processor(images=image, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model(**inputs)
post_processed_output = image_processor.post_process_depth_estimation(
outputs, target_sizes=[(image.height, image.width)],
)
depth = post_processed_output[0]["predicted_depth_uint16"].detach().cpu().numpy()
depth = Image.fromarray(depth, mode="I;16")
depth.save("depth.png")