Skip to content

Bug: AttributeError in infer() when use_fov_head=False and f_px not provided #104

Description

@McVyp

Description

When creating a model with use_fov_head=False and calling infer() without
providing f_px, the code crashes with an unhelpful AttributeError.

Steps to Reproduce

from depth_pro.depth_pro import DepthProConfig, create_model_and_transforms
import torch

config = DepthProConfig(
    patch_encoder_preset="dinov2l16_384",
    image_encoder_preset="dinov2l16_384",
    decoder_features=256,
    use_fov_head=False,
    checkpoint_uri=None,
)
model, transform = create_model_and_transforms(config=config)
model.eval()

image = torch.rand(1, 3, 256, 256)
model.infer(image)

Error

Traceback (most recent call last):
  File "<stdin>", line 26, in <module>
  File "<stdin>", line 23, in infer
AttributeError: 'NoneType' object has no attribute 'to'

Root Cause

When use_fov_head=False, forward() returns fov_deg=None.
The code unconditionally calls fov_deg.to() with no None guard.

Expected Behaviour

A clear ValueError telling the user that f_px must be provided
when use_fov_head=False.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions