The latest diffusers
added “limited” support to load LoRAs genereated with A1111 (as are commonly found on CivitAi).
This is now possible with docker-diffusers-api
too. It’s not well tested but in the latest :dev
, you can now do something like (taking note of callInputs.lora_weights
and modelInputs.prompt
):
{
"callInputs": {
"MODEL_ID": "NED-v1-22",
// Model page: https://civitai.com/models/10028/neverending-dream-ned?modelVersionId=64094
"CHECKPOINT_URL": "https://civitai.com/api/download/models/64094#fname=neverendingDreamNED_v122BakedVae.safetensors",
"MODEL_PRECISION": "fp16",
"safety_checker": false,
"PIPELINE": "lpw_stable_diffusion",
// This is the important line here, "lora_weights":
// Model page: https://civitai.com/models/5373/makima-chainsaw-man-lora
"lora_weights": "https://civitai.com/api/download/models/6244#fname=makima_offset.safetensors",
},
"modelInputs": {
// the important part here is "makima (chainsaw man)" which the LoRA introduces.
"prompt": "masterpiece, (photorealistic:1.4), best quality, beautiful lighting, (ulzzang-6500:0.5), makima \\(chainsaw man\\), (red hair)+(long braided hair)+(bangs), yellow eyes, golden eyes, ((ringed eyes)), (white shirt), (necktie), RAW photo, 8k uhd, film grain",
"num_inference_steps": 30,
"negative_prompt": "(painting by bad-artist-anime:0.9), (painting by bad-artist:0.9), watermark, text, error, blurry, jpeg artifacts, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, artist name, (worst quality, low quality:1.4), bad anatomy",
"width": 864,
"height": 1034,
"seed": 2281759351,
"guidance_scale": 9
}
}
This will download and cache the model on first use. For that reason, it’s important to specify the #fname=makima_offset.safetensors
part, so we can check in advance if we’ve previously cached the file without making an additional request every time to check the filename (which differs from the URL and comes in via a Content-Disposition
header), and - no less important - understand that the filename ends with .safetensors
. Everything after the hash (“#”) is used by docker-diffusers-api only and not sent as part of the HTTP request.
Output:
Note: We don’t have the ulzzang-6500 embedding, so it doesn’t look quite as good as the CivitAI example.