Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for image editing and upscaling for imagen3 #988

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Oct 1, 2024

  const baseImg = fs.readFileSync('base.png', { encoding: 'base64' });
  const maskImg = fs.readFileSync('mask.png', { encoding: 'base64' });

  const response = await ai.generate({
    model: imagen3,
    output: { format: 'media' },
    prompt: [
      { media: { url: `data:image/png;base64,${baseImg}` }},
      {
        media: { url: `data:image/png;base64,${maskImg}` },
        metadata: { type: 'mask' },
      },
      { text: 'replace the background with foo bar baz' },
    ],
    config: {
      editConfig: {
        editMode: 'outpainting',
      },
    },
  });

  return response.media();

js/plugins/vertexai/src/imagen.ts Outdated Show resolved Hide resolved
js/plugins/vertexai/src/imagen.ts Show resolved Hide resolved
docs/plugins/vertex-ai.md Outdated Show resolved Hide resolved
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