pythonstable-diffusion

Automatic1111 > ControlNet API sending 500 server error


I am using Automatic1111 and it is working fine on my local machine and txt2img API is also working fine but when I try to use controlNet it always gives me the server 500 response, any help or guide to where should I look for solution?

import requests
import base64

# Open the control image file in binary mode
with open("poses\poses_base.png", "rb") as f:
    # Read the image data
    image_data = f.read()

    # Encode the image data as base64
    image_base64 = base64.b64encode(image_data)

    # Convert the base64 bytes to string
    image_string = image_base64.decode("utf-8")

# Define the payload with the prompt and other parameters
payload = {
    "prompt": "A PURPLE VEST",
    "negative_prompt": "",
    "width": 512,
    "height": 512,
    "steps": 100,
    "cfg": 10,
    "sampler_index": "DPM++ 2S a Karras",
    "controlnet_units": [
        {
            "input_image": image_string,
            "mask": '',
            "module": "none",
            "model": "control_sd15_canny [fef5e48e]",
            "weight": 1.6,
            "resize_mode": "Scale to Fit (Inner Fit)",
            "lowvram": False,
            "processor_res": 512,
            "threshold_a": 64,
            "threshold_b": 64,
            "guidance": 1,
            "guidance_start": 0,
            "guidance_end": 1,
            "guessmode": True
        }
    ]
}

# Send the request to the API endpoint
response = requests.post(url=f'http://127.0.0.1:7860/controlnet/txt2img', json=payload)

# Print the response
print(response)

Solution

  • The API changed today, or yesterday. There is a new extension to the API, smth like this. Check on Automatic1111 github

    "alwayson_scripts": {
    "ControlNet": {
    "args":[True, False,
    True,
    "canny",
    "control_canny-fp16 [e3fe7712]",
    1.0,
    {"image": image_string},
    False,
    "Scale to Fit (Inner Fit)",
    False,
    False,
    64,
    64,
    64,
    0.0,
    1.0,
    False]}}