Spaces:
Runtime error
Runtime error
File size: 1,719 Bytes
91920f4 44f1fd6 91920f4 2241ae1 91920f4 2241ae1 8c80b14 91920f4 44f1fd6 e8c43c7 |
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import torch
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler, DPMSolverMultistepScheduler, \
OnnxStableDiffusionPipeline
import pipeline_openvino_stable_diffusion
from optimum.intel.openvino import OVStableDiffusionPipeline
def get_sd_21():
model_id = "stabilityai/stable-diffusion-2-1-base"
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
if torch.cuda.is_available():
pipe = StableDiffusionPipeline.from_pretrained(
model_id,
scheduler=scheduler,
# safety_checker=None,
revision="fp16",
torch_dtype=torch.float16)
pipe = pipe.to('cuda')
else:
pipe = StableDiffusionPipeline.from_pretrained(
model_id,
scheduler=scheduler,
# safety_checker=None,
revision="fp16",
torch_dtype=torch.float16)
return pipe
def get_sd_every():
model_id = 'OFA-Sys/small-stable-diffusion-v0'
scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler")
pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/stable-diffusion-2-1-quantized", compile=False)
return pipe
def get_sd_small():
pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/stable-diffusion-2-1-quantized", compile=False)
pipe.reshape(batch_size=1, height=256, width=256, num_images_per_prompt=1)
pipe.compile()
return pipe
def get_sd_tiny():
pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/stable-diffusion-2-1-quantized", compile=False)
pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)
pipe.compile()
return pipe
|