huchenlei / sd-webui-api-payload-display

Display the corresponding API payload after each generation on WebUI
MIT License
160 stars 18 forks source link

Problems implementing regional prompter #3

Closed juancopi81 closed 8 months ago

juancopi81 commented 1 year ago

Hi @huchenlei,

Thank you very much for this extension. it is very useful!

I am using the extension to try to understand how to make a Python request for the Regional Prompter extension. However, I am facing some issues, sorry if I am missing something. What I see in the extension is this:

image

And then in my code, I've tried different combinations, like:

"alwayson_scripts": {
      "Regional Prompter": {
          "args": [
              {
                  "0": True,
                  "1": False,
                  "2": "Mask",
                  "3": "Horizontal",
                  "4": "Mask",
                  "5": "Prompt",
                  "6": "1,1",
                  "7": "0.2",
                  "8": True,
                  "9": False,
                  "10": False,
                  "11": "Attention",
                  "12": False,
                  "13": "0",
                  "14": "0",
                  "15": "0.4"
              }
          ]

But it is not working. The response I get is something like:

RP Active: {\\\"0\\\": true, \\\"1\\\": false, \\\"2\\\": \\\"Mask\\\", \\\"3\\\": \\\"Horizontal\\\", \\\"4\\\": \\\"Mask\\\", \\\"5\\\": \\\"Prompt\\\", \\\"6\\\": \\\"1,1\\\", \\\"7\\\": \\\"0.2\\\", \\\"8\\\": true, \\\"9\\\": false, \\\"10\\\": false, \\\"11\\\": \\\"Attention\\\", \\\"12\\\": false, \\\"13\\\": \\\"0\\\", \\\"14\\\": \\\"0\\\", \\\"15\\\": \\\"0.4\\\"}, RP Divide mode: Matrix, RP Matrix submode: Horizontal, RP Mask submode: Mask, RP Prompt submode: Prompt, RP Calc Mode: Attention, RP Ratios: \\\"1,1\\\", RP Base Ratios: 0.2, RP Use Base: False, RP Use Common: False, RP Use Ncommon: False, RP Change AND: False, RP LoRA Neg Te Ratios: 0, RP LoRA Neg U Ratios: 0, RP threshold: 0.4, Lora hashes: \\\"add_detail: 7c6bad76eb54\\\", Version: v1.3.2\"],

So it seems to me that it is expecting some kind of nested structure that I do not see in the extension.

Thanks

huchenlei commented 1 year ago

Please check the console. Currently some structures might not be recognized by the extension. In such cases, you will see error printed on the console, e.g. currently I am not handling A1111 img2img input image format, and whenever you just img2img generation, it will print out the input image raw data onto the console.

I also noticed that you did not add the "16" param which is an image and a mask in your payload. Can you explain why?

juancopi81 commented 1 year ago

Oh I did not add it for mistake, I used to have:

"16" : {
    "image": get_b64(img),
    "mask": get_b64(img)
}

I tried something different and it seems to work better: In my code I have:

"Regional Prompter": {
      "args": [
          {"RP Divide mode": "Matrix"}, 
          {"RP Matrix submode": "Horizontal"}, 
          {"RP Mask submode": "Mask"}, 
          {"RP Prompt submode": "Prompt"}, 
          {"RP Calc Mode": "Attention"}, 
          {"RP Ratios": "1,1"}, 
          {"RP Base Ratios": 0.2}, 
          {"RP Use Base": True}

And now the response seems better:

RP Active: {\\\"RP Divide mode\\\": \\\"Matrix\\\"}, RP Divide mode: {\\\"RP Mask submode\\\": \\\"Mask\\\"}, RP Matrix submode: {\\\"RP Prompt submode\\\": \\\"Prompt\\\"}, RP Mask submode: {\\\"RP Calc Mode\\\": \\\"Attention\\\"}, RP Prompt submode: {\\\"RP Ratios\\\": \\\"1,1\\\"}, RP Calc Mode: Attention, RP Ratios: {\\\"RP Base Ratios\\\": 0.2}, RP Base Ratios: {\\\"RP Use Base\\\": true}, RP Use Base: False, RP Use Common: False, RP Use Ncommon: False, RP Change AND: False, RP LoRA Neg Te Ratios: 0, RP LoRA Neg U Ratios: 0, RP threshold: 0.4, Lora hashes: \\\"add_detail: 7c6bad76eb54\\\"

juancopi81 commented 1 year ago

The console is not showing any error: I think that the way to format the request is:

"alwayson_scripts": {
    "Regional Prompter": {
        "args": [
            True,
            False,
            "Mask",
            "Horizontal",
            "Mask",
            "Prompt",
            "1,1",
            "0.4",
            True,
            False,
            False,
            "Attention",
            False,
            "0",
            "0",
            "0.4",
            {"image": xxxx),
             "mask": xxxx},
        ]

But I am having now a problem with the img/mask