Benutzer-Werkzeuge

Webseiten-Werkzeuge


openvino

Dies ist eine alte Version des Dokuments!


Image generation mit Stable Diffusion in Python. Siehe Machine learning

python -m venv openvino_env
.\openvino_env\bin\activate
python -m pip install --upgrade pip
pip install "optimum[openvino]" pillow diffusers
# sd15_openvino.py
from optimum.intel.openvino import OVDiffusionPipeline
from PIL import Image
import time
 
# Vorgefertigtes OpenVINO-Modell
model_id = "OpenVINO/stable-diffusion-v1-5-fp16-ov"
 
# Erst GPU probieren evtl. auf "CPU" oder "AUTO" ändern.
device = "GPU"
 
prompt = "a cozy cabin in the woods at sunset, detailed, cinematic lighting"
 
start = time.time()
 
pipe = OVDiffusionPipeline.from_pretrained(
    model_id,
    device=device
)
 
images = pipe(
    prompt,
    num_inference_steps=20,
    height=512,
    width=512
).images
 
image = images[0]
image.save("output.png")
 
print(f"Fertig. Gespeichert als output.png in {time.time() - start:.1f} Sekunden auf {device}.")
openvino.1773435184.txt.gz · Zuletzt geändert: 2026/03/13 21:53 von jango