UNPKG

openvino-genai-node

Version:

OpenVINO™ GenAI pipelines for using from Node.js environment

61 lines (60 loc) 2.62 kB
import { Tensor } from "openvino-node"; import { InpaintingPipeline as InpaintingPipelineWrapper } from "../addon.js"; import { ImageGenerationPerfMetrics } from "../perfMetrics.js"; import { ImageGenerationConfig, ImageGenerationCallback, InpaintingPipelineProperties } from "../utils.js"; export type InpaintingGenerateOptions = ImageGenerationConfig & { /** * Callback invoked after each denoising step. * Return `true` to stop early, `false` to continue. */ callback?: ImageGenerationCallback; }; /** * Pipeline for inpainting. * * Generates image tensor(s) for a single prompt conditioned on an input image * and a mask that marks the region to be replaced. * Use the factory method InpaintingPipeline() to create and * initialize an instance. */ export declare class InpaintingPipeline { protected readonly modelPath: string; protected readonly device: string; protected pipeline: InpaintingPipelineWrapper | null; protected readonly properties: InpaintingPipelineProperties; constructor(modelPath: string, device: string, properties?: InpaintingPipelineProperties); /** * 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 and mask. * * Both `image` and `mask` must be `u8` Tensors with batched NHWC shape `[1, H, W, 3]` * (single image, RGB channels-last). Unbatched `[H, W, 3]` tensors are rejected. * The mask marks the region to be replaced: white pixels are repainted, black pixels are kept. * * 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, mask: Tensor, options?: InpaintingGenerateOptions): 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; }