File size: 2,365 Bytes
91920f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2241ae1
91920f4
 
8e198ad
 
 
 
 
 
 
 
2241ae1
 
 
 
8e198ad
 
 
 
 
 
 
 
 
 
91920f4
44f1fd6
 
 
8e198ad
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import torch
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler, DPMSolverMultistepScheduler, \
    OnnxStableDiffusionPipeline

import pipeline_openvino_stable_diffusion


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")

    onnx_pipe = OnnxStableDiffusionPipeline.from_pretrained(
        "OFA-Sys/small-stable-diffusion-v0",
        scheduler=scheduler,
        revision="onnx",
        provider="CPUExecutionProvider",
    )
    pipe = pipeline_openvino_stable_diffusion.OpenVINOStableDiffusionPipeline.from_onnx_pipeline(onnx_pipe)
    return pipe


def get_sd_small():
    model_id = 'OFA-Sys/small-stable-diffusion-v0'
    scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler")

    onnx_pipe = OnnxStableDiffusionPipeline.from_pretrained(
        "OFA-Sys/small-stable-diffusion-v0",
        scheduler=scheduler,
        revision="onnx",
        provider="CPUExecutionProvider",
    )
    pipe = pipeline_openvino_stable_diffusion.OpenVINOStableDiffusionPipeline.from_onnx_pipeline(onnx_pipe)
    return pipe


def get_sd_tiny():
    model_id = 'OFA-Sys/small-stable-diffusion-v0'
    scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler")

    onnx_pipe = OnnxStableDiffusionPipeline.from_pretrained(
        "OFA-Sys/small-stable-diffusion-v0",
        scheduler=scheduler,
        revision="onnx",
        provider="CPUExecutionProvider",
    )
    pipe = pipeline_openvino_stable_diffusion.OpenVINOStableDiffusionPipeline.from_onnx_pipeline(onnx_pipe)
    return pipe