Skip to content

v0.3.0 - Python Pipelines

Latest

Choose a tag to compare

@saddam213 saddam213 released this 23 Dec 21:15
· 1 commit to master since this release
5debe95

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 downloads Diffusers models from Hugging Face.

  • LoRA Support
    Load and apply LoRA models in supported pipelines.

  • CUDA Support
    Support for CUDA devices with support for ROCM in development

  • Window Demo App
    Basic Window PythonDemo App 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");
}

GitHub Downloads (all assets, specific tag)

Full Changelog: v0.2.2...v0.3.0