Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue]: Remove background failures due to onnxruntime #711

Closed
mark-wd opened this issue May 2, 2023 · 15 comments
Closed

[Issue]: Remove background failures due to onnxruntime #711

mark-wd opened this issue May 2, 2023 · 15 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mark-wd
Copy link

mark-wd commented May 2, 2023

Issue Description

As of the latest version, attempting to remove backgrounds with any of the u2net variants is giving me the error below, with or without an upsacling operation involved. I recently turned xformers on, no idea if it is related in any way.

Towards the bottom It also seems to be returning an error in the "D" drive, but well... I don't have a D drive.

ERROR    gradio call: RuntimeError
╭───────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────╮
│ G:\stable-diffusion-vladmandic\modules\call_queue.py:59 in f                                                         │
│                                                                                                                      │
│    58 │   │   │   │   pr.enable()                                                                                    │
│ ❱  59 │   │   │   res = list(func(*args, **kwargs))                                                                  │
│    60 │   │   │   if shared.cmd_opts.profile:                                                                        │
│                                                                                                                      │
│ G:\stable-diffusion-vladmandic\modules\call_queue.py:38 in f                                                         │
│                                                                                                                      │
│    37 │   │   │   try:                                                                                               │
│ ❱  38 │   │   │   │   res = func(*args, **kwargs)                                                                    │
│    39 │   │   │   │   progress.record_results(id_task, res)                                                          │
│                                                                                                                      │
│                                               ... 4 frames hidden ...                                                │
│                                                                                                                      │
│ G:\stable-diffusion-vladmandic\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py:360 in    │
│ __init__                                                                                                             │
│                                                                                                                      │
│   359 │   │   try:                                                                                                   │
│ ❱ 360 │   │   │   self._create_inference_session(providers, provider_options, disabled_optimiz                       │
│   361 │   │   except ValueError:                                                                                     │
│                                                                                                                      │
│ G:\stable-diffusion-vladmandic\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py:408 in    │
│ _create_inference_session                                                                                            │
│                                                                                                                      │
│   407 │   │   # initialize the C++ InferenceSession                                                                  │
│ ❱ 408 │   │   sess.initialize_session(providers, provider_options, disabled_optimizers)                              │
│   409                                                                                                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1106 onnxruntime::ProviderLibrary::Get
[ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load
"G:\stable-diffusion-vladmandic\venv\lib\site-packages\onnxruntime\capi\onnxruntime_providers_tensorrt.dll"

Version Platform Description

2023-05-02 hash: eb03fce

@vladmandic
Copy link
Owner

D:\xxx is the original location of the source code of the file which generated the error when onnxruntime was compiled. thats a braindead way of logging, usually done back in 80ies, but whatever.

anyhow, issue is with onnxruntime. but when you say "attempting to remove backgrounds", i don't really know what exactly do you mean - can you document exact workflow you're attempting?

@mark-wd
Copy link
Author

mark-wd commented May 2, 2023

Sure.

Process Image > Drop image into box > Set resize to "1" > Upscaler "None" > Remove background "u2net" -> Return mask and Alpha matting set to "unchecked"

The process animation is shown on the right box, fails, and the error pops up in the log.

@mark-wd mark-wd closed this as completed May 2, 2023
@mark-wd
Copy link
Author

mark-wd commented May 2, 2023

Doing a fresh install fixed the problem. Maybe recent updates broke something.

@mark-wd mark-wd reopened this May 3, 2023
@mark-wd
Copy link
Author

mark-wd commented May 3, 2023

Nope. Worked for a moment and then giving errors again: imgur

@vladmandic
Copy link
Owner

can you check: danielgatis/rembg#312 and AUTOMATIC1111/stable-diffusion-webui-rembg#3

it seems that onnxruntime library is a bit fussy.

@vladmandic vladmandic added the question Further information is requested label May 3, 2023
@mark-wd
Copy link
Author

mark-wd commented May 5, 2023

I tried following the steps, but still getting errors. The strange thing is that this is working just fine on auto1111 with the extension bolted on.

@vladmandic vladmandic added bug Something isn't working help wanted Extra attention is needed and removed question Further information is requested labels May 5, 2023
@vladmandic
Copy link
Owner

what's your onnxruntime version both here and original a1111 repo?

venv\Scripts\activate
pip show onnxruntime

@mark-wd
Copy link
Author

mark-wd commented May 8, 2023

Scratch that. Fresh installation of 1111 also failing now. I'm unable to say if it was a change to my system or a PR that was merged into both projects. Any idea on how to move forward with troubleshooting? Might be useful to other users who experience this problem now or in the future. Maybe there's also something that can be enforced from the webui side?

Library info:

Name: onnxruntime
Version: 1.14.1
Summary: ONNX Runtime is a runtime accelerator for Machine Learning models
Home-page: https://onnxruntime.ai
Author: Microsoft Corporation
Author-email: [email protected]
License: MIT License
Location: g:\stable-diffusion-vladmandic\venv\lib\site-packages
Requires: coloredlogs, flatbuffers, numpy, packaging, protobuf, sympy
Required-by: rembg

@vladmandic vladmandic changed the title [Issue]: u2net and variants failing [Issue]: Remove background failures due to onnxruntime May 9, 2023
@vladmandic
Copy link
Owner

two questions

  • what is storage behind G:\stable-diffusion-vladmandic
    G: is quite high on alphabet, is that a network mount or something like that?
  • what is the output of dir venv\lib\site-packages\onnxruntime\capi

@AimwiseTonix
Copy link

AUTOMATIC1111/stable-diffusion-webui-rembg#14
Hello, it seems that a temporary solution has been found, but it has not been adopted

@mark-wd
Copy link
Author

mark-wd commented May 11, 2023

Any chance that you could merge the above, @vladmandic?

@vladmandic
Copy link
Owner

if i merge, then copy gets out-of-sync with original and if there are any future upgrades, they wouldn't be applicable.
i'll give author one more week to merge, if not i'll have to take it and maintain copy with all the fixes.

@mark-wd
Copy link
Author

mark-wd commented May 12, 2023

Makes sense. Will wait and watch.

@mark-wd
Copy link
Author

mark-wd commented May 12, 2023

Brief update: manually "pip install onnxruntime==1.14.0" really does fix the problem. The whole issue is that ".1" version bump.

@vladmandic
Copy link
Owner

done. hope it fixes it, if not post here and i'll reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants