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

AttributeError: '_LiteModule' object has no attribute 'sample' #8

Open
TE-7000030346 opened this issue Feb 14, 2024 · 1 comment
Open

Comments

@TE-7000030346
Copy link

TE-7000030346 commented Feb 14, 2024

Dear Team, @fdbtrs @jonasgrebe @naserdamer
I'm encountering an AttributeError when running Sample.py. The error message states:

batch_samples = diffusion_model.sample(
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1260, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: '_LiteModule' object has no attribute 'sample'

This occurs when diffusionmodel.sample is called within Sample.py. However, it seems the call isn't reaching the intended diffusionmodel class. I've also observed this issue during model training while generating samples.

in sample.py

with torch.no_grad(): for _ in range(n_batches): batch_samples = diffusion_model.sample( batch_size, size, context=context)

in main.py

`
      with torch.no_grad():

            # create unconditional samples (or conditional samples with empty context)
            samples_uncond = model.sample(N_PER_BLOCK, size).cpu()
            if latent_decoder is not None:
                samples_uncond = latent_decoder(samples_uncond)
            samples_uncond = denormalize_to_zero_to_one(samples_uncond)`


_LiteModule has no attribute of sample, so it is not going to the diffusion model class how to fix this issue. thank you

@fdbtrs
Copy link
Owner

fdbtrs commented Feb 15, 2024

you need to install torch lighting < 2.0 e.g. 1.8.6. See the updated sampling instructions

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

No branches or pull requests

2 participants