ArtVentureX / sd-webui-agent-scheduler

634 stars 67 forks source link

Warning: script controlnet is not in script_runner.alwayson_scripts #102

Closed JohnnyStreet closed 1 year ago

JohnnyStreet commented 1 year ago

I can't seem to get any scripts to work in sd-webui-agent-scheduler using the same alwayson_scripts settings I use directly with the API.

artventuredev commented 1 year ago

Please update to the latest version if you can - the issue you're facing (similar to #91) has been rectified there. Hope this helps!

JohnnyStreet commented 1 year ago

@artventuredev updating did not solve it but I was able to get it working using "ControlNet" instead of "controlnet". I am still trying to figure out the formatting for other scripts, for example "face editor ex".

I have tried things like "FaceEditorEx" but I can not figure it out. I did also notice in your api.py you have this:

        # remove unused args to reduce payload size
        named_args.pop("alwayson_scripts", None)

Digging a little further, it seems you are not using lower case at this point and also you are filtering out which scripts are valid, only approving certain ones apparently. Is there a reason for not just passing the full alwayson_scripts value from the user?

    assert type(alwayson_scripts) is dict
    for script in alwayson_scripts:
        if script not in valid_alwayson_scripts:
            # allow controlnet
            if script == "ControlNet":
                script_args = get_dict_attribute(
                    alwayson_scripts, f"{script}.args", None
                )
                if script_args:
                    arg_list = map_named_script_args_to_list(script, script_args)
                    valid_alwayson_scripts[script] = {"args": arg_list}
            else:
                print(
                    f"Warning: script {script} is not in script_runner.alwayson_scripts"
                )
                # print args
                print(alwayson_scripts[script])

    params["alwayson_scripts"] = valid_alwayson_scripts

FIXED BY BYPASSING ALL OF THIS:

    # check if alwayson_scripts has script that is not in script_runner.alwayson_scripts
    #
    #assert type(alwayson_scripts) is dict
    #for script in alwayson_scripts:
    #    if script not in valid_alwayson_scripts:
    #        # allow controlnet
    #        if script == "ControlNet":
    #            script_args = get_dict_attribute(
    #                alwayson_scripts, f"{script}.args", None
    #            )
    #            if script_args:
    #                arg_list = map_named_script_args_to_list(script, script_args)
    #                valid_alwayson_scripts[script] = {"args": arg_list}
    #        else:
    #            print(
    #                f"Warning: script {script} is not in script_runner.alwayson_scripts"
    #            )
    #            # print args
    #            print(alwayson_scripts[script])
    #
    # params["alwayson_scripts"] = valid_alwayson_scripts
    params["alwayson_scripts"] = alwayson_scripts
artventuredev commented 1 year ago

Hmm, my bad. Both upper and lower case for the script title should be allowed. For now, you need to enter the correct case. I'll make a fix for this soon.

To get the correct script name, you need to read the code of the extension. It's the title of the Script class. In your case, it's Face Editor EX. Please note, however, that even with the next update, the allowed values can be face editor ex, Face Editor EX, or face Editor ex, but NOT FaceEditorEx

See https://github.com/ototadana/sd-face-editor/blob/f945fc7dadad991486cf6cbc33fb8f089404e21c/scripts/face_editor_extension.py#L15

JohnnyStreet commented 1 year ago

the allowed values can be face editor ex, Face Editor EX, or face Editor ex, but NOT FaceEditorEx

I am pretty sure I tried all of these. I have always used "face editor ex" outside of agent scheduler. It really needs to allow the same settings to be passed as they would directly to the API because there are lots of existing examples that show them in lowercase. I know it's tedious to fix but imagine how we feel having to guess or look up each extension name in their code to make sure we didn't type Ex instead of EX or something. I appreciate you taking the time to address it.

artventuredev commented 1 year ago

@JohnnyStreet The issue should be fixed in the latest update, please give it a try.

JohnnyStreet commented 1 year ago

@artventuredev Fantastic, thank you so much!

artventuredev commented 1 year ago

@JohnnyStreet There was a mistake in the previous commit, so please update one more time.

chestnutpcj commented 1 year ago

@artventuredev太棒了,非常感谢!

Can it be used correctly now?When I use alwayson_scripts: { controlnet: {args: [ { enabled: true, image: base64}]}} will report an error “string indices must be integers”?

artventuredev commented 1 year ago

Here's a working example with ControlNet:

{
  "prompt": "1girl",
  "negative_prompt": "EasyNegative",
  "alwayson_scripts": {
    "controlnet": {
      "args": [
        {
          "enabled": true,
          "image": {
            "image": "https://d2lae7oxvyyfdd.cloudfront.net/poses/5609.jpeg"
          },
          "model": "control_v11p_sd15_openpose [cab727d4]"
        }
      ]
    }
  }
}

The image field should be a Dict with "image" and an optional "mask". You can use URL or base64 for image and mask.

chestnutpcj commented 1 year ago

来件收到辣收到辣╰( ̄▽ ̄)╮