Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Torch > 2.0.1 #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AyaanShah2204
Copy link

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.

@AyaanShah2204
Copy link
Author

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

@iamwavecut
Copy link

@thias15

@philippwulff
Copy link

philippwulff commented Jan 16, 2024

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

Edit: a different interpolate call also requires typecasting

@philippwulff
Copy link

philippwulff commented Jan 16, 2024

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants