Instructions to use CompVis/stable-diffusion-v1-4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use CompVis/stable-diffusion-v1-4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", dtype=torch.bfloat16, device_map="cuda") prompt = "A high tech solarpunk utopia in the Amazon rainforest" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps
- Draw Things
- DiffusionBee
'StableDiffusionPipeline' is not defined
I running windows 10 on an I9 with a 4080 ti gpu
python version 3.9 and using Anaconda
Here is my code based on the example on the model card:
import torch
print("torch version",torch.version)
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, revision="fp32")
pipe = pipe.to(device)
pipe.enable_attention_slicing()
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]
image.save("astronaut_rides_horse.png")
C:\Users\Conda\envs\tf-gpu\python.exe C:\Users\User\Stable\SAtable_01.py
torch version 1.13.0
Traceback (most recent call last):
File "C:\Users\User\Stable\SAtable_01.py", line 4, in
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, revision="fp32")
NameError: name 'StableDiffusionPipeline' is not defined
Process finished with exit code 1
Where do I get StableDiffusionPipeline
Please advise.