ml-stable-diffusion
ml-stable-diffusion copied to clipboard
Support for negative prompts in Swift CLI
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.
I just opened a PR with the Swift implementation. See: #61