This is the OpenVINO™ version of runwayml/stable-diffusion-v1-5 (or stable-diffusion-v1-5/stable-diffusion-v1-5) .
Optimized for CPUs, especially for Intels.
Also, this version size is only about 5 GB.
1# Imports
2from optimum.intel.openvino import OVStableDiffusionPipeline
3from huggingface_hub import login
4import torch
5from pathlib import Path
6
7# Configuration
8MODEL_ID = "HARRY07979/stable-diffusion-v1-5-openvino"
9DEVICE = "cpu" # change to "gpu" if you have an Intel GPU
10DTYPE = torch.float32 if DEVICE == "cpu" else torch.float16
11
12# Load pipeline
13pipe = OVStableDiffusionPipeline.from_pretrained(
14 MODEL_ID,
15 export=True,
16 device=DEVICE,
17 torch_dtype=DTYPE,
18 safety_checker=None
19)
20
21# Generation parameters
22prompt = "A photorealistic portrait of Harry Potter, detailed, cinematic lighting"
23negative_prompt = "low quality, blurry, distorted"
24generator = torch.Generator().manual_seed(42)
25
26# Generate image
27output = pipe(
28 prompt,
29 negative_prompt=negative_prompt,
30 num_inference_steps=30,
31 guidance_scale=7.5,
32 generator=generator,
33)
34
35# Save result
36output_dir = Path("generated")
37output_dir.mkdir(parents=True, exist_ok=True)
38output.images[0].save(output_dir / "harry_potter.png")
39print(f"Image saved to {output_dir / 'harry_potter.png'}")
If you are interested with this project, you can contribute me.
This is an open project and I welcome all contributions.
Feel free to open a Pull Request!