openvino-genai-node
Version:
OpenVINO™ GenAI pipelines for using from Node.js environment
59 lines (58 loc) • 2.46 kB
TypeScript
import { Tensor } from "openvino-node";
import { Image2ImagePipeline as Image2ImagePipelineWrapper } from "../addon.js";
import { ImageGenerationPerfMetrics } from "../perfMetrics.js";
import { ImageGenerationConfig, ImageGenerationCallback, Image2ImagePipelineProperties } from "../utils.js";
export type Image2ImageGenerateOptions = ImageGenerationConfig & {
/**
* Callback invoked after each denoising step.
* Return `true` to stop early, `false` to continue.
*/
callback?: ImageGenerationCallback;
};
/**
* Pipeline for image-to-image generation.
*
* Generates image tensor(s) for a single prompt conditioned on an input image.
* Use the factory method Image2ImagePipeline() to create and
* initialize an instance.
*/
export declare class Image2ImagePipeline {
protected readonly modelPath: string;
protected readonly device: string;
protected pipeline: Image2ImagePipelineWrapper | null;
protected readonly properties: Image2ImagePipelineProperties;
constructor(modelPath: string, device: string, properties?: Image2ImagePipelineProperties);
/**
* Load the pipeline. Must be called once before generate().
*/
init(): Promise<void>;
/**
* Generate image tensor(s) for a single prompt conditioned on the input image.
*
* The input `image` must be a `u8` Tensor with batched NHWC shape `[1, H, W, 3]`
* (single image, RGB channels-last). Unbatched `[H, W, 3]` tensors are rejected.
*
* 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, image: Tensor, options?: Image2ImageGenerateOptions): 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;
}