DALL-E icon indicating copy to clipboard operation
DALL-E copied to clipboard

When I run this code in Google Colab it showing the error.

Open imostafizur opened this issue 3 years ago • 2 comments

AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'. Can you please tell me why this error occurs?

imostafizur avatar Jun 25 '22 11:06 imostafizur

I have the same error. @adityaramesh please help with this.

nimeshkasun avatar Jul 17 '22 01:07 nimeshkasun

The error 'Upsample' object has no attribute 'recompute_scale_factor'

is related to a change in the torch Upscale class from 1.10 to 1.11.

It appears that 'old' Upscale objects are saved within the model after this line of code: model = load_model("https://cdn.openai.com/dall-e/decoder.pkl", 'cuda') i used the following code immediatly after the load_model call to patch this:

# Patch for torch 1.11 and higher: replace the old Upsample object by the new version
# that exposes recompute_scale_factor
_ = model.blocks.group_1.upsample
model.blocks.group_1.upsample = torch.nn.Upsample(scale_factor = _.scale_factor, mode= _.mode)
_ = model.blocks.group_2.upsample
model.blocks.group_2.upsample = torch.nn.Upsample(scale_factor = _.scale_factor, mode= _.mode)
_ = model.blocks.group_3.upsample
model.blocks.group_3.upsample = torch.nn.Upsample(scale_factor = _.scale_factor, mode= _.mode)

and it's running fine with torch 1.12.1!

digitalShaman avatar Aug 27 '22 13:08 digitalShaman