sdwebuiapi
A Rust library for interacting with openapi of AUTOMATIC1111/stable-diffusion-webui.
Supports txt2img API calls, with controlnet 2.0 support and lora support.
The parameters for API calls are based on the documentation at http://localhost:7860/docs and have been successfully tested on webui 1.5.
Install
cargo add sdwebuiapi
Usage
webuiapi_demo.ipynb contains example code with original images. Images are compressed as jpeg in this document.
create API client
let api_auth = Some;
// or `let api_auth = None` if webui is not protected by api_auth
let client = new;
txt2img
let mut payload = TextToImagePayload ;
payload.set_base_model;
let response: TextToImageResponse = client.txt2img.await;
// the generated image is in base64 format
let raw_b64_str: &str = &response.images;
txt2img with controlnet and lora
encode image to base64, controlnet accepts raw base64 png image string, without headers
let input_image = read.unwrap;
let raw_b64_str = BASE64.encode;
build txt2img params
let controlnet_payload = ControlnetPayload ;
let lora_paylod = LoraPayload ;
let mut payload = TextToImagePayload ;
payload
.set_base_model
.add_loras
.add_controlnet_units;
generate image
let response = client.txt2img.await;