stability-sdk icon indicating copy to clipboard operation
stability-sdk copied to clipboard

Questions about the parameters and their relation to options available on the dreamstudio website

Open Abel1011 opened this issue 3 years ago • 11 comments

Good day. Thank you for this fantastic tool. I am trying to adapt the sdk to my javascript based project but I have some doubts about how to replicate certain functionalities available in dreamstudio web related to img2img.

In dreamstudio when we add an image we can define the strength parameter; however in the sdk I don't see that parameter. I understand that it is related to start and end schedule. But I would like to know the exact relation. For example, if the strength on the web is 20%, what values would have the start and end schedule?

Additionally in the sdk there is the parameter init_image and mask_image. I don't understand what is the functionality of the mask_image and if I should pass it the same value as init_image or they are different values. What functionality of dreamstudio uses the mask_image?

Thank you very much for any help you can give me.

Abel1011 avatar Sep 29 '22 15:09 Abel1011

I have questions too about what end_schedule does specifically.

As for the other variables, if you check in ./nbs/demo_colab.ipynb in this repo you can find usages of start_schedule and the mask_image. Line for start_schedule: start_schedule=0.6, # this controls the "strength" of the prompt relative to the init image

mask_image on the other hand effectively tells the AI which regions of the image to render over. This can be useful if, for example, you want to preserve a character and only change the background. You would mask the character out using mask_image.

agentx3 avatar Oct 01 '22 05:10 agentx3

But I would like to know the exact relation. For example, if the strength on the web is 20%, what values would have the start and end schedule?

Image Strength on Dreamstudio has an inverse relationship with the start_schedule parameter.

start_schedule = 1 - "Dreamstudio Image Strength" / 100

So for 20% image strength, the corresponding start_schedule parameter would be 0.8

johnsabath avatar Oct 01 '22 17:10 johnsabath

Thank you for explaining in more detail the calculation of the start schedule. Regarding the end schedule value, what is the default value used by the Dreamstudio website?

Abel1011 avatar Oct 01 '22 18:10 Abel1011

I believe a end schedule value of 0 would replicate the behavior on the Dreamstudio website.

johnsabath avatar Oct 04 '22 21:10 johnsabath

I don't think it's a 0. I tested the below on a js implementation.

From a quick test, this would be 35% Image Strength.

let imageStrength = 0.5;

//...
stepSchedule: {
	start: imageStrength,
	end: 1 - imageStrength
},

sillytuna avatar Oct 08 '22 00:10 sillytuna

Hi @sillytuna

You actually want to flip the start value, like so:

let imageStrength = 0.5;

//...
stepSchedule: {
    start: 1 - imageStrength,
    end: 0
},

will match the behaviour on the website.

Note that actually, the minimum schedule start and end values are 0.05 - so when you set end to 0, the value actually used will be 0.05. Apologies that this is not documented very well.

Let me know if this gives the behaviour you are expecting.

chigozienri avatar Oct 10 '22 15:10 chigozienri

Hmm using end of 0 didn't work. I only got comparable results, and I tested in both, using the methodology in my post.

sillytuna avatar Oct 10 '22 15:10 sillytuna

Hmm using end of 0 didn't work. I only got comparable results, and I tested in both, using the methodology in my post.

Did you use 1 - imageStrength for the start value?

chigozienri avatar Oct 10 '22 15:10 chigozienri

I did yes. IIRC I was just getting the same image back or black if end was 0, whatever else I did. I'll be revisiting the code tomorrow or weds though.

sillytuna avatar Oct 10 '22 16:10 sillytuna

I did yes. IIRC I was just getting the same image back or black if end was 0, whatever else I did. I'll be revisiting the code tomorrow or weds though.

OK, in that case try it out with end = 0.05. If you could report back any errors you see when you get a chance, that would be greatly appreciated!

chigozienri avatar Oct 10 '22 16:10 chigozienri

Hi @chigozienri , I tried setting start_ schedule=0.5 and end_ Schedule=0.05, the result is still a little different from that when dreamstudio's Image Strength=0.5. How can I achieve the same effect as dreamstudio?

I did yes. IIRC I was just getting the same image back or black if end was 0, whatever else I did. I'll be revisiting the code tomorrow or weds though.

OK, in that case try it out with end = 0.05. If you could report back any errors you see when you get a chance, that would be greatly appreciated!

ideavr avatar Oct 19 '22 13:10 ideavr