ml-stable-diffusion icon indicating copy to clipboard operation
ml-stable-diffusion copied to clipboard

Support for negative prompts in Swift CLI

Open mfellner opened this issue 2 years ago • 1 comments

As far as I could see, the Swift CLI implementation currently doesn't support negative prompts.

In the Python implementation, the negative prompt argument is tokenised, encoded into uncond_embeddings, and prepended to the text embeddings of the regular prompt: https://github.com/apple/ml-stable-diffusion/blob/583cc04ece3dce9e1e8d44449f58d2eb7edef11c/python_coreml_stable_diffusion/pipeline.py#L145-L165

The Swift implementation on the other hand does not handle a negative prompt argument: https://github.com/apple/ml-stable-diffusion/blob/583cc04ece3dce9e1e8d44449f58d2eb7edef11c/swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift#L76-L84

I don't really know how Stable Diffusion (v2) deals with negative prompts but how would one add support for them to the Swift implementation? The Core ML model seems to support it after all.

mfellner avatar Dec 11 '22 23:12 mfellner

I just opened a PR with the Swift implementation. See: #61

JustinMeans avatar Dec 12 '22 00:12 JustinMeans