OpenVINO (Open Visual Inference and Neural Network Optimization) ist ein Toolkit von Intel zur Ausführung und Optimierung von KI-Modellen auf unterschiedlicher Hardware. Es richtet sich vor allem an Anwendungen im Bereich Computer Vision, unterstützt aber auch weitere Modelltypen wie Sprach- und Generative-AI Workloads. Dazu bietet das Toolkit Funktionen zur Modellkonvertierung, Optimierung und beschleunigten Inferenz. Entwickler können damit Modelle aus gängigen Frameworks in ein kompatibles Format überführen und auf CPUs, GPUs sowie weiteren unterstützten Beschleunigern ausführen. Typische Einsatzfelder sind Bildklassifikation, Objekterkennung, Segmentierung, OCR und Videoanalyse. =====Diffusers===== Image generation mit [[StableDiffusion]] in [[coding:python|Python]]. python -m venv openvino_env .\openvino_env\bin\activate python -m pip install --upgrade pip pip install "optimum[openvino]" pillow diffusers ====Text to Image==== # 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}.") ====Image to Image==== from optimum.intel import OVStableDiffusionImg2ImgPipeline from PIL import Image import time model_id = "runwayml/stable-diffusion-v1-5" device = "GPU" # ggf. "CPU" oder "AUTO" prompt = "a cozy cabin in the woods at sunset, detailed, cinematic lighting" # Eingabebild laden init_image = Image.open("input.jpg").convert("RGB").resize((512, 512)) start = time.time() pipe = OVStableDiffusionImg2ImgPipeline.from_pretrained( model_id, export=True, # falls noch kein OpenVINO-Export vorliegt device=device ) result = pipe( prompt=prompt, image=init_image, strength=0.6, # 0.2 = näher am Original, 0.8 = freier guidance_scale=7.5, num_inference_steps=20 ).images[0] result.save("output.png") print(f"Fertig. Gespeichert als output.png in {time.time() - start:.1f} Sekunden auf {device}.") =====Links===== * [[https://huggingface.co/OpenVINO/|Huggingface]]