Skip to content

Using TransformParameters fails by insisting on image parameters #100

@d-huck

Description

@d-huck

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions