Skip to content

AttributeError: module 'fastai.vision.gan' has no attribute 'unet_config' #128

New issue

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

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

Already on GitHub? # to your account

Closed
houndcl opened this issue Mar 11, 2021 · 4 comments · Fixed by #130
Closed

AttributeError: module 'fastai.vision.gan' has no attribute 'unet_config' #128

houndcl opened this issue Mar 11, 2021 · 4 comments · Fixed by #130

Comments

@houndcl
Copy link

houndcl commented Mar 11, 2021

I am using this tutorial for super resolution Unet model. https://cran.r-project.org/web/packages/fastai/vignettes/super_res_gan.html. However, the create_gen_learner function resulted in Error in py_get_attr_impl(x, name, silent) : AttributeError: module 'fastai.vision.gan' has no attribute 'unet_config' error. The basic Unet without unet_config argument works fine. https://github.com/henry090/fastai#unet-example

create_gen_learner = function() {
  unet_learner(dls_gen, arch, loss_func = loss_gen,
               config = unet_config(blur=TRUE, norm_type = "Weight", 
               self_attention = TRUE, y_range = y_range))
}
learn_gen = create_gen_learner()
# Error in py_get_attr_impl(x, name, silent) :
#     AttributeError: module 'fastai.vision.gan' has no attribute 'unet_config'
@turgut090
Copy link
Member

Hi. Thanks for letting me know. From the python side, the tutorial is here. And as far as I understand, this function is no longer in fast.ai. https://github.com/fastai/fastai/blob/master/dev_nbs/course/lesson7-superres.ipynb

from fastai.vision.all import *
unet_config(blur=True, norm_type=NormType.Weight)
# NameError: name 'unet_config' is not defined

This could be in another place but I am not sure.

@houndcl
Copy link
Author

houndcl commented Mar 11, 2021

Thanks. fastai/fastai@eaa588f#diff-fa360114e1afbe049ed12f6aa92ac3945ceca61d72d73cec953217ddf602a1aa unet_config have been changed to create_unet_model. Based on my quick reading, it seems right now you can pass the arguments directly to unet_learner without calling unet_config or create_unet_model (please confirm!).

create_gen_learner = function() {
  unet_learner(dls_gen, arch, loss_func = loss_gen,
               blur=TRUE, norm_type = "Weight", 
               self_attention = TRUE, y_range = y_range)
}

learn_gen = create_gen_learner()
# work !

@turgut090
Copy link
Member

I think you are right. We need to add this create_unet_model, as well. I can add this. However, if you have time and would like to PR, that would be great!

@turgut090 turgut090 linked a pull request Mar 14, 2021 that will close this issue
@sheecegardezi
Copy link

fixed recipe:

bbone = resnet34
wd, y_range, loss_gen = 1e-3, (-3., 3.), MSELossFlat()

learn_gen = unet_learner(
        dls_gen, 
        bbone, 
        loss_func=loss_gen,
        blur=True, norm_type="Weight",
        self_attention=True, 
        y_range=y_range
    )

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants