DALL-E
DALL-E copied to clipboard
AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
When i install and ran the sample i am getting this error - AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor' python 3.8
Just found out a quick fix for this
Assuming you are working inside a virtual environment with python3.8 installed
- Head to
./lib/python3.8/site-packages/torch/nn/modules/upsampling.py
- Amend the
forward
method of theUpsample
class as follows:def forward(self, input: Tensor) -> Tensor: return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners) # return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners, # recompute_scale_factor=self.recompute_scale_factor)
- Restart the ipykernel and the code should work again
Alternatively, downgrading Pytorch back to <= 1.10.0 would also do the trick. Check out https://github.com/openai/DALL-E/issues/53#issuecomment-1090168903 for more details.
or see https://github.com/openai/DALL-E/issues/53#issuecomment-1090168903
You need to select the appropriate pytorch version number according to your own graphics card driver and CUDA version,that's all
------------------ 原始邮件 ------------------ 发件人: "openai/DALL-E" @.>; 发送时间: 2022年4月8日(星期五) 晚上7:29 @.>; @.***>; 主题: [openai/DALL-E] AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor' (Issue #54)
When i install and ran the sample i am getting this error - AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor' python 3.8
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Google Colab default environment throws that error as of May 2022
Just found out a quick fix for this
Assuming you are working inside a virtual environment with python3.8 installed
- Head to
./lib/python3.8/site-packages/torch/nn/modules/upsampling.py
- Amend the
forward
method of theUpsample
class as follows:def forward(self, input: Tensor) -> Tensor: return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners) # return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners, # recompute_scale_factor=self.recompute_scale_factor)
- Restart the ipykernel and the code should work again
Alternatively, downgrading Pytorch back to <= 1.10.0 would also do the trick. Check out #53 (comment) for more details.
This helps, ty
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!