File size: 628 Bytes
971c262
 
 
ba3f99d
 
 
 
 
971c262
 
 
ba3f99d
 
 
 
 
971c262
ba3f99d
 
 
 
971c262
 
 
ba3f99d
 
 
971c262
 
 
 
 
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
import torch
from optimum.intel import OVZImagePipeline

# ===== Load once =====
pipe = OVZImagePipeline.from_pretrained(
    "hsuwill000/Z-Image-Turbo-ov",
    device="cpu"
)


def generate(
    prompt,
    height=512,
    width=512,
    steps=9,
    seed=-1,
):
    if seed == -1:
        generator = torch.Generator("cpu")
    else:
        generator = torch.Generator("cpu").manual_seed(int(seed))

    image = pipe(
        prompt=prompt,
        height=int(height),
        width=int(width),
        num_inference_steps=int(steps),
        guidance_scale=0.0,
        generator=generator,
    ).images[0]

    return image