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

Using TransformParameters fails by insisting on image parameters #100

Open
d-huck opened this issue Dec 22, 2023 · 0 comments
Open

Using TransformParameters fails by insisting on image parameters #100

d-huck opened this issue Dec 22, 2023 · 0 comments

Comments

@d-huck
Copy link

d-huck commented Dec 22, 2023

Hello,

I am currently trying to use the Color Matching in golang. Here is my code:

...
req := generation.Request{
  EngineId:      "stable-diffusion-xl-1024-v1-0",
  RequestedType: generation.ArtifactType_ARTIFACT_IMAGE,
  Params: &generation.Request_Transform{
    Transform: &generation.TransformParameters{
      Transform: &generation.TransformParameters_ColorAdjust{
        ColorAdjust: &generation.TransformColorAdjust{
          MatchImage: &color_swatch,
          MatchMode:  generation.ColorMatchMode_COLOR_MATCH_RGB.Enum(),
        },
      },
    },
  },
  Prompt: []*generation.Prompt{
    {
      Prompt: &generation.Prompt_Artifact{Artifact: artifact},
    },
  },
}

generate(createGrpcCtx(context.Background(), token), client, &req)

where generate uses the code verbatim as in #49 and artifact is the returned Artifact from a previous text-based prompt. The color_swatch artifact is created with this snippet:

file, _ := os.Open("./colors.png")
defer file.Close()
stat, _ := file.Stat()
buf := make([]byte, stat.Size())
_, _ = bufio.NewReader(file).Read(buf)
color_swatch := generation.Artifact{
  Type:  generation.ArtifactType_ARTIFACT_IMAGE,
  Mime:  "image/png",
  Magic: Ptr[string]("PNG"),
  Data: &generation.Artifact_Binary{
	  Binary: buf,
  },
  Size: uint64(stat.Size()),
}

Whenever I run this code, I get the error Error after 1.063 s: rpc error: code = InvalidArgument desc = must provide image parameters. From my understanding, this implies that I should have ImageParameters as part of Params in the request, though the request itself can only have a single Param. I'm a bit at a loss as to how this should work.

My desired outcome is to simply color match a second image.

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

No branches or pull requests

1 participant