Skip to content

ValueError for Image size: Height 480 , Width 854 in RAFT #8848

@Neoyning

Description

@Neoyning

🐛 Describe the bug

...
device = "cuda" if torch.cuda.is_available() else "cpu"
raft_model = raft_small(pretrained=True, progress=False).to(device)
raft_model = raft_model.eval()
transform = transforms.ToTensor()
with torch.no_grad():
list_of_flows = raft_model(old_batch.to(device), new_batch.to(device))
...

Versions

Hi there,

I am testing the orchvision.models.optical_flow module raft_small, the code is running ok for image size (480, 752), (800,848)..
However, when I test it on Image size: Height 480 , Width 854. The code throw

ValueError: The feature encoder should downsample H and W by 8

I debug the code on https://github.com/pytorch/vision/blob/d3beb52a00e16c71e821e192bcc592d614a490c0/torchvision/models/optical_flow/raft.py#L494

fmaps = self.feature_encoder(torch.cat([image1, image2], dim=0))
fmap1, fmap2 = torch.chunk(fmaps, chunks=2, dim=0)
if fmap1.shape[-2:] != (h // 8, w // 8):
     raise ValueError("The feature encoder should downsample H and W by 8")

Image size: Height 480 , Width 854
where fmap1.shape[-2:] is torch.Size([60, 107]), h // 8 = 60, but w // 8 = 106 which triggered the ValueError.

I think this issue is related to output dimension of self.feature_encoder. Looking for help, thx~

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