Skip to content

Conversation

@shyamgupta196
Copy link

otherwise generates an error - "AttributeError: 'function' object has no attribute 'named_parameters'"

hence call model as a function

otherwise generates an error - "AttributeError: 'function' object has no attribute 'named_parameters'" 

hence call model as a function
@nitrocon
Copy link

nitrocon commented Feb 6, 2025

You have to install fastai 2.4 or change the code to use any fastai...like this:

pip install fastai

from fastai.vision.learner import create_body
from torchvision.models.resnet import resnet18
from fastai.vision.models.unet import DynamicUnet

def build_res_unet(n_input=1, n_output=2, size=256):
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
body = create_body(resnet18(), pretrained=True, n_in=n_input, cut=-2)
net_G = DynamicUnet(body, n_output, (size, size)).to(device)
return net_G

changed, now its working with the newest fastai and pytorch: body = create_body(resnet18(), pretrained=True, n_in=n_input, cut=-2)

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.

2 participants