stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Feature Request]: Expose available VAEs through the API

Open solstice-r opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What would your feature do ?

Add an API endpoint that returns a list of VAE names (and possibly hashes), so that people building an app with the Web UI as the backend can display to users which VAEs are available to choose from, removing the need to use the web interface and allowing greater automation.

Proposed workflow

The endpoint could act similarly to /sdapi/v1/sd-models, where it would return an array containing one object per VAE, with its name and optionally hashes. You'd then be able to supply either a name or hash as a POST request to /sdapi/v1/options replacing the sd_vae value to switch the VAE.

Additional information

No response

solstice-r avatar Mar 03 '23 13:03 solstice-r

I think you can try the code below: option_payload = { "sd_vae": "vae-ft-mse-840000-ema-pruned.ckpt" } res = requests.post(f'{url}/sdapi/v1/options', json.dumps(option_payload), "application/json")

finley0066 avatar Mar 14 '23 13:03 finley0066

The issue is not setting the VAE, it's getting a list of which ones can be loaded by the server, there is no endpoint for that.

solstice-r avatar Mar 14 '23 14:03 solstice-r

I want it too, now we just can got it in sd_vae.py - vae_dict

MagicReader avatar May 17 '23 06:05 MagicReader

The response will likely be large but it is possible to retrieve the VAE list and more via the /config endpoint. Look for where the elem_id is setting_sd_vae. There are no hashes because they're currently not computed for VAEs.

catboxanon avatar May 18 '23 18:05 catboxanon

https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/10845

catboxanon avatar Aug 25 '23 02:08 catboxanon