openvino-genai-node
Version:
OpenVINO™ GenAI pipelines for using from Node.js environment
55 lines (54 loc) • 2.19 kB
TypeScript
import { Tensor } from "openvino-node";
import { Text2ImagePipeline as Text2ImagePipelineWrapper } from "../addon.js";
import { ImageGenerationPerfMetrics } from "../perfMetrics.js";
import { ImageGenerationConfig, ImageGenerationCallback, Text2ImagePipelineProperties } from "../utils.js";
export type Text2ImageGenerateOptions = ImageGenerationConfig & {
/**
* Callback invoked after each denoising step.
* Return `true` to stop early, `false` to continue.
*/
callback?: ImageGenerationCallback;
};
/**
* Pipeline for text-to-image generation.
*
* Generates image tensor(s) for a single prompt.
* Use the factory method Text2ImagePipeline() to create and
* initialize an instance.
*/
export declare class Text2ImagePipeline {
protected readonly modelPath: string;
protected readonly device: string;
protected pipeline: Text2ImagePipelineWrapper | null;
protected readonly properties: Text2ImagePipelineProperties;
constructor(modelPath: string, device: string, properties?: Text2ImagePipelineProperties);
/**
* Load the pipeline. Must be called once before generate().
*/
init(): Promise<void>;
/**
* Generate image tensor(s) for a single prompt.
* Batch image generation is supported through `generationConfig.num_images_per_prompt`.
* Returned tensor shape is `[N, H, W, 3]` for batched generation and `[1, H, W, 3]` for single image.
*/
generate(prompt: string, options?: Text2ImageGenerateOptions): Promise<Tensor>;
/**
* Decode a latent image into an RGB image tensor using the VAE decoder.
*
* Useful inside a generation `callback` to obtain the intermediate image at a denoising step.
* Returned tensor shape is `[N, H, W, 3]` with `u8` pixels.
*/
decode(latent: Tensor): Promise<Tensor>;
/**
* Get performance metrics from the latest generate() call.
*/
getPerformanceMetrics(): ImageGenerationPerfMetrics;
/**
* Get current image generation config.
*/
getGenerationConfig(): ImageGenerationConfig;
/**
* Update image generation config.
*/
setGenerationConfig(config: ImageGenerationConfig): void;
}