AttributeError: 'AutoencoderKLOutput' object has no attribute 'sample'
See original GitHub issueDescribe 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) <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’
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”
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Here the updated notebook: https://github.com/huggingface/notebooks/blob/main/diffusers/image_2_image_using_diffusers.ipynb (much fewer lines as well 😃)
I’m assuming you’re using the old image 2 image script, like I was doing on Easy Diffusion. This is no longer needed. You can just import the image 2 image pipeline.