lllyasviel / stable-diffusion-webui-forge

GNU Affero General Public License v3.0
8.55k stars 839 forks source link

I would prefer it to support sd or flux through the api #2264

Closed dhp666 closed 2 weeks ago

dhp666 commented 2 weeks ago

Does forge currently support the flux api? I found that the previous parameters could not use the flux model, or I would prefer it to support sd or flux through the api

altoiddealer commented 2 weeks ago

Yes, forge can use flux just fine via the API.

You may post to the 'options' endpoint a dictionary containing the sd_checkpoint_model (string), forge_additional_modules (list of strings, can use short names like ['ae.safetensors', 'etc'], forge_inference_memory (integer), etc - and those values will be set persistently.

You may also use the same dictionary structure for an override_settings in txt2img or img2img payloads, which would apply only to the current request (not set persistently).

One thing to note about forge_inference_memory is that, via the API, it is kind of the inverse of GPU Weights in the UI. Meaning if you have 12gb vram and you use a setting like 8000 GPU weights in the UI, you would instead use the parameter 'forge_inference_memory': 4000

dhp666 commented 2 weeks ago

thanks~~

dhp666 commented 2 weeks ago

def register(options_templates, options_section, OptionInfo): options_templates.update(options_section((None, "Forge Hidden options"), { "forge_unet_storage_dtype": OptionInfo('Automatic'), "forge_inference_memory": OptionInfo(1024), "forge_async_loading": OptionInfo('Queue'), "forge_pin_shared_memory": OptionInfo('CPU'), "forge_preset": OptionInfo('sd'), "forge_additional_modules": OptionInfo([]), })) Are these parameters supported in the over settings api?

altoiddealer commented 2 weeks ago

Any options obtained via the options endpoint (GET) may be applied via options endpoint (POST), or override_settings (txt2img / img2img)

To answer your question - Yes! :)

dhp666 commented 2 weeks ago

thanks,very good

dengtianbi commented 1 week ago

May I ask if you executed successfully? Could you provide an example of a successful execution call? Thank you very much.

altoiddealer commented 1 week ago

May I ask if you executed successfully? Could you provide an example of a successful execution call? Thank you very much.

When you are using the webui, in the addess bar add “/docs” to the end of the address and go, this will open the API UI. From here, use the GET method for Options endpoint (“try it out”). Now, copy the json format values, and paste them into the POST method for Options endpoint, except feel free to change the values.

When you execute it you will see it works.