Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to manually set the seed for the SD pipeline #998

Merged
merged 1 commit into from
Sep 4, 2023
Merged

Allow to manually set the seed for the SD pipeline #998

merged 1 commit into from
Sep 4, 2023

Conversation

maxjcohen
Copy link
Contributor

Description

Enable setting the seed for the stable diffusion pipeline. This is done through an additional seed parameter in the request, such as:

curl http://localhost:8080/v1/images/generations \
    -H "Content-Type: application/json" \
    -d '{"model": "stablediffusion", "prompt": "prompt", "n": 1, "step": 51, "size": "512x512", "seed": 3}'

Notes for Reviewers
When the seed parameter is not sent, request.seed defaults to 0, making it difficult to detect an actual seed of 0. Is there a way to change the default to -1 for instance ?

Signed commits

  • Yes, I signed my commits.

@mudler
Copy link
Owner

mudler commented Sep 3, 2023

to allow a seed of '0' we should change the request parameters to be a pointer of an int - do you want to take a stab at it? For me we can merge this one and iterate on another PR

Copy link
Owner

@mudler mudler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

@maxjcohen
Copy link
Contributor Author

to allow a seed of '0' we should change the request parameters to be a pointer of an int - do you want to take a stab at it? For me we can merge this one and iterate on another PR

Sure, I'll open a new PR for this one. I don't have much experience in Go, but I'm guessing I have to mess with this part of the code:
https://github.com/go-skynet/LocalAI/blob/0e7e8eec5305607bbc63306f97b418e91fdd9875/pkg/grpc/proto/backend.pb.go#L1151-L1168

@mudler
Copy link
Owner

mudler commented Sep 4, 2023

to allow a seed of '0' we should change the request parameters to be a pointer of an int - do you want to take a stab at it? For me we can merge this one and iterate on another PR

Sure, I'll open a new PR for this one. I don't have much experience in Go, but I'm guessing I have to mess with this part of the code:

https://github.com/go-skynet/LocalAI/blob/0e7e8eec5305607bbc63306f97b418e91fdd9875/pkg/grpc/proto/backend.pb.go#L1151-L1168

here: https://github.com/go-skynet/LocalAI/blob/0e7e8eec5305607bbc63306f97b418e91fdd9875/api/config/prediction.go#L36

@mudler mudler merged commit f9d2bd2 into mudler:master Sep 4, 2023
8 checks passed
mudler added a commit that referenced this pull request Sep 4, 2023
**Description**

Follow up of #998 - respect the device used to load the model and do not
specify a seed in the parameters, but rather just configure the
generator as described in
https://huggingface.co/docs/diffusers/using-diffusers/reusing_seeds

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@maxjcohen maxjcohen deleted the feat/diffusers/add-seed branch September 4, 2023 19:29
@mudler mudler added the enhancement New feature or request label Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants