Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
export type StreamingImageKind = 'fallback' | 'final' | 'live';
export interface DenoiseProgressImage {
dataUrl: string;
height: number;
width: number;
}
export interface StreamingImageSource {
alt: string;
height?: number;
kind: StreamingImageKind;
src: string;
width?: number;
}
export const mergeDenoiseProgressImage = <Image extends DenoiseProgressImage>(
previous: Image | null | undefined,
next: Image | null | undefined
): Image | null | undefined => (next === undefined ? previous : next);
export const progressImageToStreamingSource = (
image: DenoiseProgressImage | null | undefined,
alt = 'In-progress diffusion preview'
): StreamingImageSource | null =>
image
? {
alt,
height: image.height,
kind: 'live',
src: image.dataUrl,
width: image.width,
}
: null;
export const imageUrlToStreamingSource = ({
alt,
height,
kind = 'final',
src,
width,
}: {
alt: string;
height?: number;
kind?: Exclude<StreamingImageKind, 'live'>;
src: string | null | undefined;
width?: number;
}): StreamingImageSource | null =>
src
? {
alt,
height,
kind,
src,
width,
}
: null;
export const resolveStreamingImageSource = ({
fallbackImage,
finalImage,
liveImage,
}: {
fallbackImage?: StreamingImageSource | null;
finalImage?: StreamingImageSource | null;
liveImage?: StreamingImageSource | null;
}): StreamingImageSource | null => finalImage ?? liveImage ?? fallbackImage ?? null;