Python Pipelines
You can now run Diffusers Python pipelines directly from C#, with everything managed for you.
-
Automatic Python Setup
Downloads and installs an isolated Python runtime — no system Python required. -
Device-Specific Virtual Environments
Creates a dedicated virtual environment tailored to the selected device. -
Hugging Face Model Downloads
Automatically downloadsDiffusersmodels from Hugging Face. -
LoRA Support
Load and apply LoRA models in supported pipelines. -
CUDA Support
Support forCUDAdevices with support forROCMin development -
Window Demo App
Basic WindowPythonDemoApp available for download below
Supported Diffusers Pipelines
Chroma
- ChromaPipeline
- ChromaImg2ImgPipeline
Qwen Image
- QwenImagePipeline
- QwenImageImg2ImgPipeline
- QwenImageEditPipeline
Wan Video
- WanPipeline
- WanImageToVideoPipeline
Z-Image
- ZImagePipeline
- ZImageImg2ImgPipeline
Basic Example
Python Virtual Environment
The PythonManager can be used to download and install Python and create virtual environments
// Virtual Environment Config
var serverConfig = new EnvironmentConfig
{
Environment = "default-cuda",
Directory = "PythonRuntime",
Requirements =
[
"--extra-index-url https://download.pytorch.org/whl/cu118",
"torch==2.7.0+cu118",
"typing",
"wheel",
"transformers",
"accelerate",
"diffusers",
"protobuf",
"sentencepiece",
"pillow",
"ftfy",
"scipy",
"peft"
]
};
// PythonManager
var pythonManager = new PythonManager(serverConfig);
// Create/Load Virtual Environment
await pythonManager .CreateEnvironmentAsync(PipelineProgress.ConsoleCallback);Python Pipelines
Once you have created a virtual environment you can now load a pipeline
// Pipeline Config
var pipelineConfig = new PipelineConfig
{
Path = "Qwen/Qwen-Image-Edit",
Pipeline = "QwenImagePipeline",
ProcessType = ProcessType.ImageEdit,
IsFullOffloadEnabled = true,
DataType = DataType.Bfloat16
};
// Create Pipeline Proxy
using (var pythonPipeline = new PythonPipeline(pipelineConfig, PipelineProgress.ConsoleCallback))
{
// Download/Load Model
await pythonPipeline.LoadAsync();
// Generate Option
var options = new PipelineOptions
{
Prompt = "Yarn art style",
Steps = 30,
Width = 1024,
Height = 1024,
GuidanceScale = 4f,
Scheduler = SchedulerType.FlowMatchEulerDiscrete,
ImageInput = new ImageInput("Image.png")
};
// Generate
var response = await pythonPipeline.GenerateAsync(options);
// Save Image
await response
.AsImageTensor()
.SaveAsync("Result.png");
}Full Changelog: v0.2.2...v0.3.0