Crate diffusion_rs_core

Source
Expand description

Core crate for interacting with diffusion_rs.

The API is intentionally straightforward but strives to provide strong flexibility.

use std::time::Instant;

use diffusion_rs_core::{DiffusionGenerationParams, ModelSource, Offloading, Pipeline, TokenSource};

let pipeline = Pipeline::load(
    ModelSource::dduf("FLUX.1-dev-Q4-bnb.dduf")?,
    true,
    TokenSource::CacheToken,
    None,
    None,
)?;

let start = Instant::now();

let images = pipeline.forward(
    vec!["Draw a picture of a sunrise.".to_string()],
    DiffusionGenerationParams {
        height: 720,
        width: 1280,
        num_steps: 50,
        guidance_scale: 3.5,
    },
)?;

let end = Instant::now();
println!("Took: {:.2}s", end.duration_since(start).as_secs_f32());

images[0].save("image.png")?;

Structs§

DiffusionGenerationParams
Generation parameters.
Pipeline
Represents the model and provides methods to load and interact with it.

Enums§

ModelSource
Source from which to load the model. This is easiest to create with the various constructor functions.
Offloading
Offloading setting during loading.
TokenSource
The source of the HF token.