Skip to content

AttributeError: 'AutoencoderKLOutput' object has no attribute 'sample' #431

@nunezmatias

Description

@nunezmatias

Describe the bug

running notebook https://colab.research.google.com/github/patil-suraj/Notebooks/blob/master/image_2_image_using_diffusers.ipynb

when running this cell (after previously run all the preceding cell )

generator = torch.Generator(device=device).manual_seed(1024)
with autocast("cuda"):
images = pipe(prompt=prompt, init_image=init_image, generator=generator)["sample"]
! images = pipe(prompt=prompt, init_image=init_image, strength=0.75, guidance_scale=7.5, generator=generator)["sample"]

I get this output


AttributeError Traceback (most recent call last)
in
1 generator = torch.Generator(device=device).manual_seed(1024)
2 with autocast("cuda"):
----> 3 images = pipe(prompt=prompt, init_image=init_image, generator=generator)["sample"]
4 get_ipython().system(' images = pipe(prompt=prompt, init_image=init_image, strength=0.75, guidance_scale=7.5, generator=generator)["sample"]')

1 frames
in call(self, prompt, init_image, strength, num_inference_steps, guidance_scale, eta, generator, output_type)
56
57 # encode the init image into latents and scale the latents
---> 58 init_latents = self.vae.encode(init_image.to(self.device)).sample()
59 init_latents = 0.18215 * init_latents
60

AttributeError: 'AutoencoderKLOutput' object has no attribute 'sample'

Reproduction

generator = torch.Generator(device=device).manual_seed(1024)
with autocast("cuda"):
images = pipe(prompt=prompt, init_image=init_image, generator=generator)["sample"]
! images = pipe(prompt=prompt, init_image=init_image, strength=0.75, guidance_scale=7.5, generator=generator)["sample"]

Logs

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-18-01521f904f0c> in <module>
      1 generator = torch.Generator(device=device).manual_seed(1024)
      2 with autocast("cuda"):
----> 3     images = pipe(prompt=prompt, init_image=init_image, generator=generator)["sample"]
      4 get_ipython().system('    images = pipe(prompt=prompt, init_image=init_image, strength=0.75, guidance_scale=7.5, generator=generator)["sample"]')

1 frames
<ipython-input-5-4fb8144e2978> in __call__(self, prompt, init_image, strength, num_inference_steps, guidance_scale, eta, generator, output_type)
     56 
     57         # encode the init image into latents and scale the latents
---> 58         init_latents = self.vae.encode(init_image.to(self.device)).sample()
     59         init_latents = 0.18215 * init_latents
     60 

AttributeError: 'AutoencoderKLOutput' object has no attribute 'sample'

System Info

Same colab as its on this site as yesterday.

Thu Sep 8 17:43:09 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |
| N/A 37C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |
| | | N/A |

the libs intsalled

!pip install -qq -U diffusers transformers ftfy
!pip install -qq "ipywidgets>=7,<8"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions