Skip to content

ImageGenerationParameterExtension.WithPhotomaker() #77

Description

@Zurzar

Title: ImageGenerationParameterExtension.WithPhotomaker() is a no-op — doesn't set any parameter

Version: StableDiffusion.NET 7.0.0 (NuGet)

Description:

While trying to use PhotoMaker for face-consistent generation, I decompiled StableDiffusion.NET.dll and found that WithPhotomaker() on ImageGenerationParameter doesn't actually do anything — it just returns the parameter object unchanged:

public static ImageGenerationParameter WithPhotomaker(this ImageGenerationParameter parameter, string inputIdImageDirectory, float? styleStrength = null, bool? normalizeInput = null)
{
    return parameter;
}

The signature looks correct (matches stable-diffusion.cpp's --input-id-images-dir, --style-ratio, --normalize-input flags), but none of the arguments are stored anywhere on parameter.

For context: DiffusionModelParameter.WithPhotomaker(string stackedIdEmbeddingsDirectory) (on the model, not the generation params) does correctly set parameter.StackedIdEmbeddingsDirectory, — but there's no way to actually pass the reference/id images through the public API, since this generation-level method is empty.

Expected behavior: the method should set something like parameter.InputIdImageDirectory, parameter.StyleStrength, parameter.NormalizeInput (or equivalent fields consumed by the native call), matching how WithControlNet() or WithRefImages() populate their respective fields.

Repro:

using DiffusionModel sd = new(DiffusionModelParameter.Create()
    .WithModelPath("<sdxl_model>")
    .WithPhotomaker("<path_to_photomaker-v2.safetensors>"));

var img = sd.GenerateImage(ImageGenerationParameter
    .TextToImage("a woman img, 40 years old, photorealistic")
    .WithPhotomaker("<path_to_id_images_dir>", styleStrength: 20f)
    .WithSDXLDefaults());

No error is thrown, but the id images are silently ignored since nothing in WithPhotomaker() propagates them further.

Happy to test a fix if you point me in the right direction — thanks for maintaining this project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions