Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is needed for reproducible generations, if I want to generate the same image again, the prompt and noise is sufficient. Currently, the noise tensor is generated random (no seed) inside
StreamDiffusion
(pipeline.py).I added a noise argument (default=None) to
StreamDiffusionWrapper
(wrapper.py) andStreamDiffusion
(pipeline.py) for thetxt2img
variants and the__call__
method, to allow the called to specify this. It works for batch sizes larger than 1 as well.The user can either:
None
(or omit it) to maintain current, unseeded latent vectorList[int]
(of lengthbatch_size
) to use each element as a deterministic seed for one batch elementint
, which is shorthand forList[int]
only whenbatch_size == 1
torch.Tensor
, which must be of the proper size, and allows the user to have full control of the noise tensorI also exposed two more methods from
StreamDiffusion
, which could be used by advanced users to create and manipulate the noise vectors further (eg. create "similar" variants, but slowly deviating from the noise vector that created the given image). These arenoise_size
(to show the required input size) andnoise_from_seeds
, which is the internal generation method for theList[int]
case, in case further processing is desired.Note: I didn't know how to write automated tests on this codebase, but I modified the code in
examples/optimal_performace
to use this in both single image and batch generations, with different configurations and manually confirmed it works. I will push in a second commit commented out, so you can quickly try this.