Spaces:
Runtime error
Runtime error
File size: 858 Bytes
d9dec00 4fd608e d9dec00 e2d516b d9dec00 e5fc540 e83334f 44ee31d d9dec00 aaa1cf1 d9dec00 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import torch
from diffusers import StableDiffusionImg2ImgPipeline
import os
TOKEN = os.environ.get('TOKEN_SD') or True
torch.cuda.empty_cache()
device = "cpu"
def pipe_image(prompt,
init_image=None,
strength=0.6):
pipe = StableDiffusionImg2ImgPipeline.from_pretrained("CompVis/stable-diffusion-v1-4",
revision="fp16",
torch_dtype=torch.float32,
use_auth_token=TOKEN
)
pipe = pipe.to(device)
#pipe.enable_attention_slicing()
images = pipe(prompt=prompt,
init_image=init_image,
strength=strength,
guidance_scale=7.5,
)
return images |