Skip to content

feat(vertexai): add Virtual Try-On model support#278

Draft
CorieW wants to merge 6 commits into
mainfrom
@invertase/vertex-add-virtual-try-on
Draft

feat(vertexai): add Virtual Try-On model support#278
CorieW wants to merge 6 commits into
mainfrom
@invertase/vertex-add-virtual-try-on

Conversation

@CorieW

@CorieW CorieW commented May 6, 2026

Copy link
Copy Markdown
Member

Adds Virtual Try On model to VertexAI plugin.

Testing

The following puts a shirt (image A) onto a person (image B):

Image A
image

Image B
image

Result
image

Params
image

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Virtual Try-On models in the Vertex AI plugin, including the implementation of model options, request/response mapping, and integration into the plugin's model resolution and discovery logic. Feedback focuses on improving integration with the Genkit framework by defining a JSON schema for VirtualTryOnOptions and ensuring it is passed as customOptions in model references, metadata, and constructors. Additionally, it was suggested to disable systemRole support as the current implementation only processes media parts and does not handle text instructions.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/genkit_vertexai/lib/genkit_vertexai.dart (69)

medium

The virtualTryOn method should pass VirtualTryOnOptions.$schema as customOptions to modelRef. This ensures that the model configuration is properly typed and validated by the Genkit framework, especially when used through the CLI or developer UI.

    return modelRef(
      'vertexai/$name',
      config: config,
      customOptions: VirtualTryOnOptions.$schema,
    );

packages/genkit_vertexai/lib/src/virtual_try_on.dart (15-18)

medium

Add the schemantic import to support defining the JSON schema for VirtualTryOnOptions.

import 'dart:convert';

import 'package:genkit/plugin.dart';
import 'package:genkit_google_genai/common.dart';
import 'package:schemantic/schemantic.dart';

packages/genkit_vertexai/lib/src/virtual_try_on.dart (28)

medium

The Virtual Try-On model does not appear to support system instructions or text prompts based on the implementation of _toVirtualTryOnPredictRequest, which only extracts media parts. Setting systemRole: true might be misleading; it should likely be false unless the model actually processes text instructions.

    'systemRole': false,

packages/genkit_vertexai/lib/src/virtual_try_on.dart (33-44)

medium

To integrate properly with Genkit's schema validation and UI, VirtualTryOnOptions should provide a JSON schema via a static $schema field.

class VirtualTryOnOptions {
  VirtualTryOnOptions({
    this.outputOptions,
    this.sampleCount,
    this.storageUri,
    this.seed,
    this.baseSteps,
    this.safetySetting,
    this.personGeneration,
    this.addWatermark,
    this.enhancePrompt,
  });

  static final $schema = SchemanticType.object(
    properties: {
      'outputOptions': SchemanticType.any(),
      'sampleCount': SchemanticType.integer(),
      'storageUri': SchemanticType.string(),
      'seed': SchemanticType.integer(),
      'baseSteps': SchemanticType.integer(),
      'safetySetting': SchemanticType.string(),
      'personGeneration': SchemanticType.string(),
      'addWatermark': SchemanticType.boolean(),
      'enhancePrompt': SchemanticType.boolean(),
    },
  );
}

packages/genkit_vertexai/lib/src/virtual_try_on.dart (75-80)

medium

Include customOptions in the model metadata to ensure the framework is aware of the configuration schema when listing models.

ActionMetadata virtualTryOnModelMetadata(String pluginName, String modelName) {
  return modelMetadata(
    '$pluginName/$modelName',
    modelInfo: virtualTryOnModelInfo,
    customOptions: VirtualTryOnOptions.$schema,
  );
}

packages/genkit_vertexai/lib/src/virtual_try_on.dart (92)

medium

The Model constructor should include customOptions so that the framework can validate and parse the request configuration against the VirtualTryOnOptions schema.

    name: '$pluginName/$modelName',
    customOptions: VirtualTryOnOptions.$schema,
    metadata: {'model': virtualTryOnModelInfo.toJson()},

@CorieW

CorieW commented May 10, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Virtual Try-On models within the Genkit Vertex AI plugin. Key changes include the addition of the virtualTryOn method to the VertexAiPluginHandle, implementation of the model logic in a new virtual_try_on.dart file, and the inclusion of comprehensive unit tests. Feedback was provided to improve the validation of image URIs by explicitly checking for unsupported URI schemes to prevent invalid API requests.

Comment thread packages/genkit_vertexai/lib/src/virtual_try_on.dart Outdated
@cabljac cabljac self-requested a review May 29, 2026 10:27
Comment thread packages/genkit_vertexai/lib/src/virtual_try_on.dart Outdated
@CorieW

CorieW commented Jun 2, 2026

Copy link
Copy Markdown
Member Author
  • Test changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants