stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: Lora cannot be loaded in API mode

Open GGBond8488 opened this issue 2 years ago • 19 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

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

GGBond8488 avatar Feb 21 '23 10:02 GGBond8488

Do you mind sharing your POST payload?

fbarretto avatar Feb 23 '23 18:02 fbarretto

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"
}

alkaideemo avatar Feb 24 '23 05:02 alkaideemo

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"
}

GGBond8488 avatar Feb 24 '23 05:02 GGBond8488

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?

Chopin68 avatar Feb 24 '23 08:02 Chopin68

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

amliuxin avatar Feb 25 '23 17:02 amliuxin

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"

sleep2death avatar Feb 27 '23 19:02 sleep2death

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

GGBond8488 avatar Mar 01 '23 08:03 GGBond8488

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!

PromptExpert avatar Mar 06 '23 02:03 PromptExpert

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

tenghui98 avatar Apr 04 '23 05:04 tenghui98

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?

954L avatar Apr 08 '23 16:04 954L

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()"

Noobmaster6978 avatar Apr 18 '23 17:04 Noobmaster6978

@Noobmaster6978 image

2424004764 avatar Apr 19 '23 08:04 2424004764

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

2424004764 avatar Apr 19 '23 08:04 2424004764

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 avatar Apr 19 '23 19:04 Noobmaster6978

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

Noobmaster6978 avatar Apr 25 '23 15:04 Noobmaster6978

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

Noobmaster6978 avatar Apr 25 '23 15:04 Noobmaster6978

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

SunSoul avatar Apr 27 '23 07:04 SunSoul

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

Insadem avatar May 05 '23 16:05 Insadem

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

ktncktnc avatar May 08 '23 03:05 ktncktnc

It doesn't work in the latest version

Javinciii avatar May 12 '23 02:05 Javinciii

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

ibrainventures avatar May 12 '23 18:05 ibrainventures

The fix worked for me

zhangyic0 avatar Jun 05 '23 05:06 zhangyic0

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

conanak99 avatar Aug 05 '23 20:08 conanak99

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

catboxanon avatar Aug 07 '23 14:08 catboxanon