Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Compatibility with Torch > 2.0.1 - #60

Open
ayaannshah wants to merge 1 commit into
isl-org:mainfrom
ayaannshah:torch_update
Open

ayaannshah wants to merge 1 commit into
isl-org:mainfrom
ayaannshah:torch_update

Conversation

@ayaannshah

Copy link
Copy Markdown

Hello @shariqfarooq123

We're working with the latest nightly version of torch. They seem to have added type asserts to interpolate (this commit).

This causes a runtime error because the size we pass in is of type numpy.int32. A simple int-cast should fix this without any side effects.

@ayaannshah

Copy link
Copy Markdown
Author

@thias15 could you please merge this? It causes issues with newer torch versions :)

@iamwavecut

Copy link
Copy Markdown
@philippwulff

philippwulff commented Jan 16, 2024 •

Copy link
Copy Markdown

Would be helpful if someone could merge this one :) @thias15 @shariqfarooq123

Edit: a different interpolate call also requires typecasting

@philippwulff

philippwulff commented Jan 16, 2024 •

Copy link
Copy Markdown

Monkey-patching interpolate may be a workaround:

# Backup the original interpolate function
original_interpolate = F.interpolate

def patched_interpolate(input, size=None, scale_factor=None, mode='nearest', align_corners=None, recompute_scale_factor=None):
    if size is not None:
        size = tuple(int(s) for s in size)
    return original_interpolate(input, size, scale_factor, mode, align_corners, recompute_scale_factor)

model = torch.hub.load("isl-org/ZoeDepth", "ZoeD_K", pretrained=True).cuda()

F.interpolate = patched_interpolate
depths_zoe = model.infer(imgs)
F.interpolate = original_interpolate
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants