Z-Image-Turbo-ov / inference.py
HelloSun's picture
Update inference.py
ba3f99d verified
raw
history blame contribute delete
628 Bytes
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