pub struct ImageSession { /* private fields */ }Expand description
A loaded, resident text-to-image pipeline. Build once with Self::load,
then call Self::render per prompt.
Implementations§
Source§impl ImageSession
impl ImageSession
Sourcepub fn load(
dit_gguf: &Path,
vae_weights: &Path,
te_source: &TeSource,
tokenizer_dir: &Path,
) -> Result<Self, PipelineError>
pub fn load( dit_gguf: &Path, vae_weights: &Path, te_source: &TeSource, tokenizer_dir: &Path, ) -> Result<Self, PipelineError>
Load every model asset and keep it resident.
te_source selects the 4-bit MLX safetensors or the f32 .npy dir, same
as crate::pipeline::TextToImageCfg. The text encoder is put in
resident mode so its dequantised weights persist across renders.
§Errors
PipelineError wrapping whichever asset failed to load.
Sourcepub fn warm(&self) -> Result<Duration, PipelineError>
pub fn warm(&self) -> Result<Duration, PipelineError>
Populate the resident text-encoder cache so the first real render runs at warm speed. A single short encode touches every layer’s weights, so one pass dequantises the whole encoder. Returns how long warming took.
DiT and VAE weights are memory-mapped and page in lazily; this only warms the encoder, which is the dominant amortizable (re-dequant) cost.
§Errors
PipelineError if the warm-up encode fails.
Sourcepub fn render(
&self,
params: &RenderParams,
) -> Result<RenderOutcome, PipelineError>
pub fn render( &self, params: &RenderParams, ) -> Result<RenderOutcome, PipelineError>
Render one image. Reuses the resident weights; nothing is re-loaded.
§Errors
PipelineError wrapping whichever stage failed.
Auto Trait Implementations§
impl !Freeze for ImageSession
impl !RefUnwindSafe for ImageSession
impl !Send for ImageSession
impl !Sync for ImageSession
impl Unpin for ImageSession
impl UnsafeUnpin for ImageSession
impl UnwindSafe for ImageSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more