AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
140.41k stars 26.58k forks source link

[Bug]: Lora cannot be loaded in API mode #7984

Closed GGBond8488 closed 1 year ago

GGBond8488 commented 1 year ago

Is there an existing issue for this?

What happened?

when I run webui --api to start a simple api only server, and I post a http request ,it show

Skipping unknown extra network: lora 100%|████████████████████████████████████████████████████████████████████████████████████████████| 40/40 [00:11<00:00, 3.39it/s] INFO: 127.0.0.1:38420 - "POST /sdapi/v1/txt2img HTTP/1.1" 200 OK INFO: 127.0.0.1:38647 - "POST /sdapi/v1/png-info HTTP/1.1" 200 OK

And I check the web.py, It seems that lora is not registered,for some reason I can't access the web page, so I don't konw if lora works

Steps to reproduce the problem

  1. download release package
  2. download diffusion and lora checkpoint file
  3. run webui.sh to prepare env
  4. exec ./webui.sh --nowebapi
  5. and it occurs

What should have happened?

Skipping unknown extra network: lora shouldn't happen

Commit where the problem happens

release v1.0.0-pre

What platforms do you use to access the UI ?

No response

What browsers do you use to access the UI ?

No response

Command Line Arguments

./webui.sh --nowebui

List of extensions

No

Console logs

Skipping unknown extra network: lora
100%|████████████████████████████████████████████████████████████████████████████████████████████| 40/40 [00:10<00:00,  3.68it/s]
INFO:     127.0.0.1:39473 - "POST /sdapi/v1/txt2img HTTP/1.1" 200 OK
INFO:     127.0.0.1:39758 - "POST /sdapi/v1/png-info HTTP/1.1" 200 OK

Additional information

No response

fbarretto commented 1 year ago

Do you mind sharing your POST payload?

alkaideemo commented 1 year ago

Do you mind sharing your POST payload?

I got the same warning, lora model was ignored.

{
    "prompt": "best quality, ultra high res, (photorealistic:1.4), 1girl, brown blazer, black skirt, glasses, thighhighs, ((T shirt)), (upper body), (Kpop idol), (aegyo sal:1), (platinum   blonde hair:1), ((puffy eyes)), looking at viewer, facing front, smiling, <lora:koreanDollLikeness_v10:0.66>",
    "negative_prompt": "nsfw, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, age spot, glan",
    "steps": 28,
    "cfg_scale": 8,
    "width": 768,
    "height": 1024,
    "n_iter": 4,
    "sampler_index": "DPM++ SDE Karras"
}
GGBond8488 commented 1 year ago

this is my payload, and I can load the lora with webui

payload = {
"prompt": "<lora:koreanDollLikeness_v10:1>, (8k, RAW photo, best quality, masterpiece:1.2),(realistic, photo-realistic:1.37),omertosa,1lady, (aegyo sal:1),city,professional lighting,photon mapping, radiosity, physically-based rendering,  blue backlight bokeh, smile, mature,head portrait,sunlight,blone,short jacket,school uniform, hoodie, short hair, floating hair",
"Negative prompt": "EasyNegative, paintings, sketches, EasyNegative, paintings, sketches,  lowres, normal quality, ((monochrome)), ((grayscale)),skin spots, acnes, skin blemishes, age spot,glans,extra fingers,fewer fingers,strange fingers, bad hand, high heel shoes, fat ass,hole,kid,teen,cute,naked, Ripped jeans,hole jeans, fat thigh,6 fingers, bikini,underwear, nsfw, nude, briefs,knickers, underpants,panties, swim suit,leg open",
"steps": 40,
"Sampler": "DPM++ 2M Karras",
"CFG scale": "7",
"Seed": 3534095324,
"Model": "chilloutmix_NiPrunedFp32",
"height":"768",
"width":"512",
"Denoising strength": 1,
"Hires upscale":1,
"Hires steps":40,
"Hires upscaler":"Latent"
}
Chopin68 commented 1 year ago

this is my payload, and I can load the lora with webui

payload = {
    "prompt": "<lora:koreanDollLikeness_v10:1>, (8k, RAW photo, best quality, masterpiece:1.2),(realistic, photo-realistic:1.37),omertosa,1lady, (aegyo sal:1),city,professional lighting,photon mapping, radiosity, physically-based rendering,  blue backlight bokeh, smile, mature,head portrait,sunlight,blone,short jacket,school uniform, hoodie, short hair, floating hair",
    "Negative prompt": "EasyNegative, paintings, sketches, EasyNegative, paintings, sketches,  lowres, normal quality, ((monochrome)), ((grayscale)),skin spots, acnes, skin blemishes, age spot,glans,extra fingers,fewer fingers,strange fingers, bad hand, high heel shoes, fat ass,hole,kid,teen,cute,naked, Ripped jeans,hole jeans, fat thigh,6 fingers, bikini,underwear, nsfw, nude, briefs,knickers, underpants,panties, swim suit,leg open",
    "steps": 40,
    "Sampler": "DPM++ 2M Karras",
    "CFG scale": "7",
    "Seed": 3534095324,
    "Model": "chilloutmix_NiPrunedFp32",
    "height":"768",
    "width":"512",
    "Denoising strength": 1,
    "Hires upscale":1,
    "Hires steps":40,
    "Hires upscaler":"Latent"
}

Is your Superresolution valid? I don't seem to increase the image resolution, even though "Hires upscale": 2. By the way, have you tried the hires.fox of img2img?

amliuxin commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203 I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

sleep2death commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

Yes, it's a bug with the "API"

GGBond8488 commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

after adding this, it works, thank you very much

PromptExpert commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

works for me, well done! Thanks!

tenghui98 commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

Thank you bro. it works

954L commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

Thank you bro. it works

@tenpha I changed it so that I won't go wrong, but it still doesn't work. What about you?

Noobmaster6978 commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

Im a noob in coding, can you explain where is this "def api_only()"

2424004764 commented 1 year ago

@Noobmaster6978 image

2424004764 commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

我发现这个变量extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>},lora 在 api 启动后没有注册。 并且 lora 在这一行中作为扩展加载:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

我复制modules.script_callbacks.before_ui_callback()到 def api_only(),效果很好

it works

Noobmaster6978 commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

我发现这个变量extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>},lora 在 api 启动后没有注册。 并且 lora 在这一行中作为扩展加载: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

我复制modules.script_callbacks.before_ui_callback()到 def api_only(),效果很好

it works

Thank you for your time. But I'm on Collab so can't edit directly, So I downloaded the "webui.py" and edited it locally then reuploaded it in its folder in place of the old file in google drive. But after running SD when I checked, the file was back to the original one and my issue didn't got resolved. It's still showing the error: "Skipping unknown extra network: [loraname_version]". What am I doing wrong?

Noobmaster6978 commented 1 year ago

Tried this solution to fix the bug for the past few days. Its not working for me

Noobmaster6978 commented 1 year ago

Tried this solution to fix the bug for the past few days. Its not working for me

SunSoul commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

Thank you. it works

Insadem commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/extra_networks.py#L69

I found this variable extra_network_registry={'hypernet': <modules.extra_networks_hypernet.ExtraNetworkHypernet object at 0x000002181B293F70>}, lora is not registried after api launch. And lora was loaded as extension in this line:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/webui.py#L203

I copyed modules.script_callbacks.before_ui_callback() into def api_only(), and works well

Yes, this works very well! Thank you

ktncktnc commented 1 year ago

Tried this solution to fix the bug for the past few days. Its not working for me

Edit the webui.py file first, and then you need to restart the process

Javinciii commented 1 year ago

It doesn't work in the latest version

ibrainventures commented 1 year ago

updated today our stack ( [5ab7f213] - latest release 2nd of May 23) and this "patch" is still working fine.

for workflow / Docker we are using this little sed patch. RUN sed -i -e '/ api = create_api/a\' -e ' modules.script_callbacks.before_ui_callback()' webui.py

zhangyic0 commented 1 year ago

The fix worked for me

conanak99 commented 1 year ago

Why is this still a bug and not fixed in the API >.<?

catboxanon commented 1 year ago

Merged in dev. https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/12387