repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTaskBuilder.withImageGenerationParameters
public withImageGenerationParameters(imageGenerationParameters: ImageGenerationParameters) { this.props.imageGenerationParameters = imageGenerationParameters; return (this); }
/** * @param imageGenerationParameters the image generation parameters. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L163-L166
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTaskBuilder.build
public build(): ImageInpaintingTask { return (ImageInpaintingTask.from(this.props)); }
/** * @returns a new instance of the `ImageInpaintingTask` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L172-L174
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.constructor
constructor(public props: ImageInpaintingProps) { if (!props.maskImage && !props.maskPrompt) { throw new Error('Must specify either mask image or mask prompt.'); } if (props.maskImage && props.maskPrompt) { throw new Error('Cannot specify both mask image and mask prompt.'); } }
/** * Creates a new instance of the `ImageInpaintingTask` class. * @param props the task properties. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L191-L198
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.text
public text() { return (this.props.text); }
/** * @returns the text prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L203-L205
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.negativeText
public negativeText() { return (this.props.negativeText); }
/** * @returns the negative text prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L210-L212
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.image
public image() { return (this.props.image); }
/** * @returns the image prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L217-L219
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.maskPrompt
public maskPrompt() { return (this.props.maskPrompt); }
/** * @returns the mask prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L224-L226
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.maskImage
public maskImage() { return (this.props.maskImage); }
/** * @returns the mask image associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L231-L233
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.imageGenerationParameters
public imageGenerationParameters() { return (this.props.imageGenerationParameters); }
/** * @returns the image generation parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L238-L240
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.from
public static from(props: any) { return (new ImageInpaintingTask(ImageInpaintingTaskPropsSchema.parse(props))); }
/** * Creates a new instance of the `ImageInpaintingTask` class. * @param props the task properties. * @returns a new instance of the `ImageInpaintingTask` class. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L247-L249
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageInpaintingTask.toJSON
public toJSON() { return (this.props); }
/** * @returns the JSON representation of the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-inpainting-task.ts#L254-L256
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.withTextPrompt
public withTextPrompt(prompt: string | dsl.IReference<any>) { let reference = null; if (typeof prompt === 'string') { reference = dsl.reference(dsl.value(prompt)); } else { reference = prompt; } this.props.text = reference; return (this); }
/** * @param prompt the text prompt to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L101-L112
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.withTextNegativePrompt
public withTextNegativePrompt(negativePrompt: string | dsl.IReference<any>) { let reference = null; if (typeof negativePrompt === 'string') { reference = dsl.reference(dsl.value(negativePrompt)); } else { reference = negativePrompt; } this.props.negativeText = reference; return (this); }
/** * @param negativePrompt the negative text prompt to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L118-L129
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.withImage
public withImage(image: dsl.IReference<any>) { this.props.image = image; return (this); }
/** * @param image sets a reference to the image to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L135-L138
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.withMaskPrompt
public withMaskPrompt(maskPrompt: string | dsl.IReference<any>) { let reference = null; if (typeof maskPrompt === 'string') { reference = dsl.reference(dsl.value(maskPrompt)); } else { reference = maskPrompt; } this.props.maskPrompt = reference; return (this); }
/** * @param maskPrompt the mask prompt to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L144-L155
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.withMaskImage
public withMaskImage(maskImage: dsl.IReference<any>) { this.props.maskImage = maskImage; return (this); }
/** * @param maskImage the mask image to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L161-L164
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.withOutPaintingMode
public withOutPaintingMode(outPaintingMode: 'DEFAULT' | 'PRECISE') { this.props.outPaintingMode = outPaintingMode; return (this); }
/** * @param outPaintingMode the outpainting mode to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L170-L173
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.withImageGenerationParameters
public withImageGenerationParameters(imageGenerationParameters: ImageGenerationParameters) { this.props.imageGenerationParameters = imageGenerationParameters; return (this); }
/** * @param imageGenerationParameters the image generation parameters. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L179-L182
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTaskBuilder.build
public build(): ImageOutpaintingTask { return (ImageOutpaintingTask.from(this.props)); }
/** * @returns a new instance of the `ImageOutpaintingTask` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L188-L190
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.constructor
constructor(public props: ImageOutpaintingProps) { if (!props.maskImage && !props.maskPrompt) { throw new Error('Must specify either mask image or mask prompt.'); } if (props.maskImage && props.maskPrompt) { throw new Error('Cannot specify both mask image and mask prompt.'); } }
/** * Creates a new instance of the `ImageOutpaintingTask` class. * @param props the task properties. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L207-L214
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.text
public text() { return (this.props.text); }
/** * @returns the text prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L219-L221
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.negativeText
public negativeText() { return (this.props.negativeText); }
/** * @returns the negative text prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L226-L228
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.image
public image() { return (this.props.image); }
/** * @returns the image prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L233-L235
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.maskPrompt
public maskPrompt() { return (this.props.maskPrompt); }
/** * @returns the mask prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L240-L242
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.maskImage
public maskImage() { return (this.props.maskImage); }
/** * @returns the mask image associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L247-L249
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.outPaintingMode
public outPaintingMode() { return (this.props.outPaintingMode); }
/** * @returns the outpainting mode associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L254-L256
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.imageGenerationParameters
public imageGenerationParameters() { return (this.props.imageGenerationParameters); }
/** * @returns the image generation parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L261-L263
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.from
public static from(props: any) { return (new ImageOutpaintingTask(ImageOutpaintingTaskPropsSchema.parse(props))); }
/** * Creates a new instance of the `ImageOutpaintingTask` class. * @param props the task properties. * @returns a new instance of the `ImageOutpaintingTask` class. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L270-L272
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageOutpaintingTask.toJSON
public toJSON() { return (this.props); }
/** * @returns the JSON representation of the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-outpainting-task.ts#L277-L279
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTaskBuilder.withTextPrompt
public withTextPrompt(prompt: string | dsl.IReference<any>) { let reference = null; if (typeof prompt === 'string') { reference = dsl.reference(dsl.value(prompt)); } else { reference = prompt; } this.props.text = reference; return (this); }
/** * @param prompt the text prompt to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L90-L101
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTaskBuilder.withTextNegativePrompt
public withTextNegativePrompt(negativePrompt: string | dsl.IReference<any>) { let reference = null; if (typeof negativePrompt === 'string') { reference = dsl.reference(dsl.value(negativePrompt)); } else { reference = negativePrompt; } this.props.negativeText = reference; return (this); }
/** * @param negativePrompt the negative text prompt to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L107-L118
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTaskBuilder.withImage
public withImage(image: dsl.IReference<any>) { this.props.image = image; return (this); }
/** * @param image sets a reference to the image to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L124-L127
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTaskBuilder.withSimilarityStrength
public withSimilarityStrength(similarityStrength: number) { this.props.similarityStrength = similarityStrength; return (this); }
/** * @param similarityStrength the similarity strength to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L133-L136
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTaskBuilder.withImageGenerationParameters
public withImageGenerationParameters(imageGenerationParameters: ImageGenerationParameters) { this.props.imageGenerationParameters = imageGenerationParameters; return (this); }
/** * @param imageGenerationParameters the image generation parameters. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L142-L145
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTaskBuilder.build
public build(): ImageVariationTask { return (ImageVariationTask.from(this.props)); }
/** * @returns a new instance of the `ImageVariationTask` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L151-L153
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.constructor
constructor(public props: ImageVariationProps) {}
/** * Creates a new instance of the `ImageVariationTask` class. * @param props the task properties. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L170-L170
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.text
public text() { return (this.props.text); }
/** * @returns the text prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L175-L177
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.negativeText
public negativeText() { return (this.props.negativeText); }
/** * @returns the negative text prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L182-L184
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.image
public image() { return (this.props.image); }
/** * @returns the image prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L189-L191
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.similarityStrength
public similarityStrength() { return (this.props.similarityStrength); }
/** * @returns the similarity strength associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L196-L198
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.imageGenerationParameters
public imageGenerationParameters() { return (this.props.imageGenerationParameters); }
/** * @returns the image generation parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L203-L205
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.from
public static from(props: any) { return (new ImageVariationTask(ImageVariationTaskPropsSchema.parse(props))); }
/** * Creates a new instance of the `ImageVariationTask` class. * @param props the task properties. * @returns a new instance of the `ImageVariationTask` class. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L212-L214
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ImageVariationTask.toJSON
public toJSON() { return (this.props); }
/** * @returns the JSON representation of the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/image-variation-task.ts#L219-L221
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTaskBuilder.withPrompt
public withPrompt(prompt: string | dsl.IReference<any>) { let reference = null; if (typeof prompt === 'string') { reference = dsl.reference(dsl.value(prompt)); } else { reference = prompt; } this.props.text = reference; return (this); }
/** * @param prompt the text prompt to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L98-L109
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTaskBuilder.withNegativePrompt
public withNegativePrompt(negativePrompt: string | dsl.IReference<any>) { let reference = null; if (typeof negativePrompt === 'string') { reference = dsl.reference(dsl.value(negativePrompt)); } else { reference = negativePrompt; } this.props.negativeText = reference; return (this); }
/** * @param negativePrompt the negative text prompt to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L115-L126
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTaskBuilder.withControlMode
public withControlMode(controlMode: 'CANNY_EDGE' | 'SEGMENTATION') { this.props.controlMode = controlMode; return (this); }
/** * @param controlMode the conditioning mode to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L132-L135
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTaskBuilder.withConditionImage
public withConditionImage(conditionImage: dsl.IReference<any>) { this.props.conditionImage = conditionImage; return (this); }
/** * @param conditionImage the conditioning image to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L141-L144
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTaskBuilder.withControlStrength
public withControlStrength(controlStrength: number) { this.props.controlStrength = controlStrength; return (this); }
/** * @param controlStrength the conditioning strength to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L150-L153
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTaskBuilder.withImageGenerationParameters
public withImageGenerationParameters(imageGenerationParameters: ImageGenerationParameters) { this.props.imageGenerationParameters = imageGenerationParameters; return (this); }
/** * @param imageGenerationParameters the image generation parameters. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L159-L162
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTaskBuilder.build
public build(): TextToImageTask { return (TextToImageTask.from(this.props)); }
/** * @returns a new instance of the `TextToImageTask` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L168-L170
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.constructor
constructor(public props: TextToImageProps) {}
/** * Creates a new instance of the `TextToImageTask` class. * @param props the task properties. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L187-L187
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.prompt
public prompt() { return (this.props.text); }
/** * @returns the prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L192-L194
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.negativePrompt
public negativePrompt() { return (this.props.negativeText); }
/** * @returns the negative prompt associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L199-L201
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.controlMode
public controlMode() { return (this.props.controlMode); }
/** * @returns the conditioning mode associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L206-L208
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.conditionImage
public conditionImage() { return (this.props.conditionImage); }
/** * @returns the conditioning image associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L213-L215
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.controlStrength
public controlStrength() { return (this.props.controlStrength); }
/** * @returns the conditioning strength associated with the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L220-L222
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.imageGenerationParameters
public imageGenerationParameters() { return (this.props.imageGenerationParameters); }
/** * @returns the image generation parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L227-L229
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.from
public static from(props: any): TextToImageTask { return (new TextToImageTask(TextToImageTaskPropsSchema.parse(props))); }
/** * Creates a new instance of the `TextToImageTask` class. * @param props the task properties. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L235-L237
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TextToImageTask.toJSON
public toJSON() { return (this.props); }
/** * @returns the JSON representation of the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/definitions/tasks/text-to-image-task.ts#L242-L244
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.processEvent
private async processEvent(event: CloudEvent) { let images: Buffer[] = []; // By default, we set the seed to a random value if // it is not defined by the user. if (!TASK.imageGenerationParameters.seed) { (TASK.imageGenerationParameters.seed as any) = Math.floor(Math.random() * 214783647); } // Execute the task. if (TASK.taskType === 'TEXT_IMAGE') { images = await textToImage(event, IMAGE_MODEL, TASK); } else if (TASK.taskType === 'INPAINTING') { images = await imageInpainting(event, IMAGE_MODEL, TASK); } else if (TASK.taskType === 'OUTPAINTING') { images = await imageOutpainting(event, IMAGE_MODEL, TASK); } else if (TASK.taskType === 'IMAGE_VARIATION') { images = await imageVariation(event, IMAGE_MODEL, TASK); } else if (TASK.taskType === 'BACKGROUND_REMOVAL') { images = await backgroundRemoval(event, IMAGE_MODEL, TASK); } else if (TASK.taskType === 'COLOR_GUIDED_GENERATION') { images = await colorGuidedGeneration(event, IMAGE_MODEL, TASK); } else { throw new Error(`Unsupported task type`); } // Upload the images and forward them to the next middlewares. for (const [idx, image] of images.entries()) { await this.onImage(idx, image, event); } }
/** * Generates an image using a Bedrock model and * the given parameters. * @param event the CloudEvent to process. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/lambdas/handler/index.ts#L108-L138
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.recordHandler
async recordHandler(record: SQSRecord): Promise<any> { return (await this.processEvent( CloudEvent.from(record.body) )); }
/** * @param record the SQS record to process that contains * the EventBridge event providing information about the * S3 event. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/lambdas/handler/index.ts#L145-L149
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
public async handler(event: SQSEvent, _: Context) { return (await processPartialResponse( event, this.recordHandler.bind(this), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/amazon/lambdas/handler/index.ts#L159-L163
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGeneratorBuilder.withImageModel
public withImageModel(model: SdxlImageModel) { this.middlewareProps.imageModel = model; return (this); }
/** * Sets the Bedrock image model to use for generating * images. * @param model the Bedrock image model to use. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L82-L85
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGeneratorBuilder.withModelParameters
public withModelParameters(parameters: ModelParameters) { this.middlewareProps.modelParameters = parameters; return (this); }
/** * Sets the parameters to pass to the image model. * @param parameters the parameters to pass to the image model. * @default {} */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L92-L95
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGeneratorBuilder.withPrompt
public withPrompt(prompt: string | r.IReference<any>) { let reference = null; if (typeof prompt === 'string') { reference = r.reference(r.value(prompt)); } else { reference = prompt; } this.middlewareProps.prompt = reference; return (this); }
/** * Sets the prompt to use for generating images. * @param prompt the prompt to use for generating images. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L101-L112
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGeneratorBuilder.withNegativePrompts
public withNegativePrompts(prompts: Array<string | r.IReference<any>>) { const references = []; for (const prompt of prompts) { if (typeof prompt === 'string') { references.push(r.reference(r.value(prompt))); } else { references.push(prompt); } } this.middlewareProps.negativePrompts = references; return (this); }
/** * Sets the negative prompts to use when generating images. * @param prompts the negative prompts to use when generating images. * @default [] */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L119-L132
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGeneratorBuilder.withRegion
public withRegion(region: string) { this.middlewareProps.region = region; return (this); }
/** * Sets the AWS region in which the model * will be invoked. * @param region the AWS region in which the model * will be invoked. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L140-L143
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGeneratorBuilder.build
public build(): SdxlImageGenerator { return (new SdxlImageGenerator( this.scope, this.identifier, { ...this.middlewareProps as SdxlImageGeneratorProps, ...this.props } )); }
/** * @returns a new instance of the `SdxlImageGenerator` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L149-L157
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGenerator.constructor
constructor(scope: Construct, id: string, private props: SdxlImageGeneratorProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 2 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. this.props = this.parse(SdxlImageGeneratorPropsSchema, props); /////////////////////////////////////////// //////// Processing Storage /////// /////////////////////////////////////////// this.storage = new CacheStorage(this, 'Storage', { encryptionKey: this.props.kmsKey }); /////////////////////////////////////////// ////// Middleware Event Handler //// /////////////////////////////////////////// this.eventProcessor = new node.NodejsFunction(this, 'Compute', { description: 'Generates images using SDXL on Amazon Bedrock.', entry: path.resolve(__dirname, 'lambdas', 'handler', 'index.js'), vpc: this.props.vpc, memorySize: this.props.maxMemorySize ?? DEFAULT_MEMORY_SIZE, timeout: PROCESSING_TIMEOUT, runtime: EXECUTION_RUNTIME, architecture: lambda.Architecture.ARM_64, tracing: lambda.Tracing.ACTIVE, environmentEncryption: this.props.kmsKey, logGroup: this.logGroup, insightsVersion: this.props.cloudWatchInsights ? LAMBDA_INSIGHTS_VERSION : undefined, environment: { POWERTOOLS_SERVICE_NAME: description.name, POWERTOOLS_METRICS_NAMESPACE: NAMESPACE, SNS_TARGET_TOPIC: this.eventBus.topicArn, PROCESSED_FILES_BUCKET: this.storage.id(), IMAGE_MODEL: this.props.imageModel.name, PROMPT: JSON.stringify(this.props.prompt), NEGATIVE_PROMPTS: JSON.stringify(this.props.negativePrompts), MODEL_PARAMETERS: JSON.stringify(this.props.modelParameters), BEDROCK_REGION: this.props.region ?? '' }, bundling: { minify: true, externalModules: [ '@aws-sdk/client-s3', '@aws-sdk/client-sns', '@aws-sdk/client-bedrock-runtime' ] } }); // Allows this construct to act as a `IGrantable` // for other middlewares to grant the processing // lambda permissions to access their resources. this.grantPrincipal = this.eventProcessor.grantPrincipal; // Plug the SQS queue into the lambda function. this.eventProcessor.addEventSource(new sources.SqsEventSource(this.eventQueue, { batchSize: this.props.batchSize ?? 1, maxConcurrency: this.props.maxConcurrency ?? 2, reportBatchItemFailures: true })); // Allow access to the Bedrock API. this.eventProcessor.addToRolePolicy(new iam.PolicyStatement({ effect: iam.Effect.ALLOW, actions: [ 'bedrock:InvokeModel' ], resources: [ `arn:${cdk.Aws.PARTITION}:bedrock:${this.props.region ?? cdk.Aws.REGION}::foundation-model/${this.props.imageModel.name}`, ] })); // Grant the compute type permissions to // write to the post-processing bucket. this.storage.grantWrite(this.grantPrincipal); // Grant the compute type permissions to // publish to the SNS topic. this.eventBus.grantPublish(this.grantPrincipal); super.bind(); }
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L184-L274
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGenerator.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L280-L282
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGenerator.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain', 'image/png', 'image/jpeg', 'application/json+scheduler' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L288-L295
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGenerator.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'image/png' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L301-L305
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGenerator.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L311-L315
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageGenerator.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/index.ts#L324-L329
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SdxlImageModel.of
public static of(name: string) { return (new SdxlImageModel(name)); }
/** * Create a new instance of the `SdxlImageModel` * by name. * @param name the name of the model. * @returns a new instance of the `SdxlImageModel`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/definitions/image-model.ts#L34-L36
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getPrompts
async getPrompts(event: CloudEvent): Promise<object[]> { const negativePrompts = []; for (const negativePrompt of NEGATIVE_PROMPTS) { negativePrompts.push({ text: (await event.resolve(negativePrompt)).toString(), weight: -1.0 }); } return ([{ text: (await event.resolve(PROMPT)).toString(), weight: 1.0 }, ...negativePrompts]); }
/** * Generates an array of prompt attributes (both positive and negative) * to be used for generating images. * @param event the CloudEvent to process. * @returns a promise that resolves to the list of prompt * to use for generating images. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/lambdas/handler/index.ts#L78-L92
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getInitImage
async getInitImage(event: CloudEvent): Promise<string | undefined> { if (!MODEL_PARAMETERS.init_image) { return (Promise.resolve(undefined)); } return ((await event.resolve(MODEL_PARAMETERS.init_image)).toString('base64')); }
/** * @param event the CloudEvent to process. * @returns a promise that resolves to the init image * to use for generating images in base 64, or `undefined` if * no init image is specified. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/lambdas/handler/index.ts#L100-L105
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getMaskImage
async getMaskImage(event: CloudEvent): Promise<string | undefined> { if (!MODEL_PARAMETERS.mask_image) { return (Promise.resolve(undefined)); } return ((await event.resolve(MODEL_PARAMETERS.mask_image)).toString('base64')); }
/** * @param event the CloudEvent to process. * @returns a promise that resolves to the mask image * to use for inpainting generation in base 64, or `undefined` if * no mask image is specified. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/lambdas/handler/index.ts#L113-L118
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.recordHandler
async recordHandler(record: SQSRecord): Promise<CloudEvent> { return (await this.processEvent( CloudEvent.from(record.body) )); }
/** * @param record the SQS record to process that contains * the EventBridge event providing information about the * S3 event. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/lambdas/handler/index.ts#L175-L179
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
public async handler(event: SQSEvent, _: Context) { return (await processPartialResponse( event, this.recordHandler.bind(this), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/bedrock-image-generators/src/impl/sdxl/lambdas/handler/index.ts#L189-L193
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Blip2ImageProcessorBuilder.withMaxInstances
public withMaxInstances(maxInstances: number) { this.providerProps.maxInstances = maxInstances; return (this); }
/** * The maximum amount of instances the * cluster can have. Keep this number to * a reasonable value to avoid over-provisioning * the cluster. * @param maxInstances the maximum amount of instances. * @default 5 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/blip2-image-processor/src/index.ts#L68-L71
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Blip2ImageProcessorBuilder.build
public build(): Blip2ImageProcessor { return (new Blip2ImageProcessor( this.scope, this.identifier, { ...this.providerProps as Blip2ImageProcessorProps, ...this.props } )); }
/** * @returns a new instance of the `Blip2ImageProcessor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/blip2-image-processor/src/index.ts#L77-L85
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Blip2ImageProcessor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { // Since this middleware simply passes through the data // from the previous middleware, we grant any subsequent // middlewares in the pipeline read access to the // data of all source middlewares. for (const source of this.sources) { source.grantReadProcessedDocuments(grantee); } return ({} as iam.Grant); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/blip2-image-processor/src/index.ts#L181-L190
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Blip2ImageProcessor.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'image/bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'image/webp', 'image/x-pcx' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/blip2-image-processor/src/index.ts#L196-L206
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Blip2ImageProcessor.supportedOutputTypes
supportedOutputTypes(): string[] { return (this.supportedInputTypes()); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/blip2-image-processor/src/index.ts#L212-L214
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Blip2ImageProcessor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.GPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/blip2-image-processor/src/index.ts#L220-L224
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Blip2ImageProcessor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/blip2-image-processor/src/index.ts#L233-L238
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetectorBuilder.withLowerThreshold
public withLowerThreshold(lowerThreshold: number) { this.providerProps.lowerThreshold = lowerThreshold; return (this); }
/** * Sets the lower threshold of the hysteresis procedure. * Edges with intensity gradients below this value will be discarded. * @default 100 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L70-L73
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetectorBuilder.withUpperThreshold
public withUpperThreshold(upperThreshold: number) { this.providerProps.upperThreshold = upperThreshold; return (this); }
/** * Sets the upper threshold of the hysteresis procedure. * Edges with intensity gradients above this value will be considered strong edges. * @default 200 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L80-L83
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetectorBuilder.withApertureSize
public withApertureSize(apertureSize: 3 | 5 | 7) { this.providerProps.apertureSize = apertureSize; return (this); }
/** * Sets the size of the Sobel kernel used for edge detection. * This parameter affects the level of detail in the edges detected. * @note valid values are 3, 5, and 7. * @default 3 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L91-L94
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetectorBuilder.withL2Gradient
public withL2Gradient(l2Gradient: boolean) { this.providerProps.l2Gradient = l2Gradient; return (this); }
/** * Specifies the equation for finding gradient magnitude. * @default false */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L100-L103
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetectorBuilder.build
public build(): CannyEdgeDetector { return (new CannyEdgeDetector( this.scope, this.identifier, { ...this.providerProps as CannyEdgeDetectorProps, ...this.props } )); }
/** * @returns a new instance of the `CannyEdgeDetector` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L109-L117
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetector.constructor
constructor(scope: Construct, id: string, private props: CannyEdgeDetectorProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 3 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validating the properties. this.props = this.parse(CannyEdgeDetectorPropsSchema, props); /////////////////////////////////////////// //////// Processing Storage /////// /////////////////////////////////////////// this.storage = new CacheStorage(this, 'Storage', { encryptionKey: this.props.kmsKey }); /////////////////////////////////////////// /////// Processing Function /////// /////////////////////////////////////////// this.eventProcessor = new lambda.DockerImageFunction(this, 'Compute', { description: 'Creates a canny edge image.', code: lambda.DockerImageCode.fromImageAsset( path.resolve(__dirname, 'lambdas', 'processor') ), vpc: this.props.vpc, memorySize: this.props.maxMemorySize ?? DEFAULT_MEMORY_SIZE, timeout: PROCESSING_TIMEOUT, architecture: lambda.Architecture.X86_64, tracing: lambda.Tracing.ACTIVE, environmentEncryption: this.props.kmsKey, logGroup: this.logGroup, insightsVersion: props.cloudWatchInsights ? LAMBDA_INSIGHTS_VERSION : undefined, environment: { POWERTOOLS_SERVICE_NAME: description.name, POWERTOOLS_METRICS_NAMESPACE: NAMESPACE, SNS_TARGET_TOPIC: this.eventBus.topicArn, LAKECHAIN_CACHE_STORAGE: this.props.cacheStorage.id(), PROCESSED_FILES_BUCKET: this.storage.id(), LOWER_THRESHOLD: `${this.props.lowerThreshold}`, UPPER_THRESHOLD: `${this.props.upperThreshold}`, APERTURE_SIZE: `${this.props.apertureSize}`, L2_GRADIENT: this.props.l2Gradient ? 'True' : 'False' } }); // Allows this construct to act as a `IGrantable` // for other middlewares to grant the processing // lambda permissions to access their resources. this.grantPrincipal = this.eventProcessor.grantPrincipal; // Plug the SQS queue into the lambda function. this.eventProcessor.addEventSource(new sources.SqsEventSource(this.eventQueue, { batchSize: this.props.batchSize ?? 2, reportBatchItemFailures: true })); // Function permissions. this.eventBus.grantPublish(this.eventProcessor); this.storage.grantWrite(this.eventProcessor); super.bind(); }
/** * Provider constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L144-L211
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetector.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L217-L219
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetector.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'image/jpeg', 'image/png', 'image/bmp', 'image/webp' ]); }
/** * @returns an array of mime-types supported as input * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L225-L232
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetector.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'image/png' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L238-L242
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetector.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L248-L252
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CannyEdgeDetector.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/canny-edge-detector/src/index.ts#L261-L266
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
HashingImageProcessorBuilder.withAverageHashing
public withAverageHashing(averageHashing: boolean): HashingImageProcessorBuilder { this.providerProps.averageHashing = averageHashing; return (this); }
/** * Sets whether to compute the average hash of images. * @default true * @param averageHashing whether to compute the average hash of images. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/hashing-image-processor/src/index.ts#L70-L73
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
HashingImageProcessorBuilder.withPerceptualHashing
public withPerceptualHashing(perceptualHashing: boolean): HashingImageProcessorBuilder { this.providerProps.perceptualHashing = perceptualHashing; return (this); }
/** * Sets whether to compute the perceptual hash of images. * @default true * @param perceptualHashing whether to compute the perceptual hash of images. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/image-processors/hashing-image-processor/src/index.ts#L81-L84
4285173e80584eedfc1a8424d3d1b6c1a7038088