File size: 743 Bytes
2ec2ebd
ea8200b
2ec2ebd
 
 
 
ca6c1fd
 
 
 
 
 
0378b53
c0237de
0378b53
5b7fb44
c0237de
b1e8435
c0237de
2ec2ebd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
import torch

pipeline = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)

# Check if CUDA is available and set the device accordingly
device = "cuda" if torch.cuda.is_available() else "cpu"

# Move the pipeline to the device
pipeline.to(device)

def get_images(prompt, skip_layers):
    print('inside get images')
    print(f'skipping {skip_layers}')
    pipeline_output = pipeline(prompt, clip_skip=skip_layers, num_images_per_prompt=1, return_tensors=False)
    print('after pipeline')
    images = pipeline_output.images
    print('got images')
    return images