Gourieff / sd-webui-reactor

Fast and Simple Face Swap Extension for StableDiffusion WebUI (A1111 SD WebUI, SD WebUI Forge, SD.Next, Cagliostro)
GNU Affero General Public License v3.0
2.45k stars 262 forks source link

[SOLVED] onnxruntime.capi.onnxruntime_pybind11_state.InvalidProtobuf: [ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model inswapper_128.onnx failed:Protobuf parsing failed #137

Closed gharmonica closed 10 months ago

gharmonica commented 10 months ago

First, confirm

What happened?

Reactor fails at the faceswapping step.

Steps to reproduce the problem

I installed the extension Had to use the steps shown in the troubleshooting II

The extension seems to be running normally, but when I try to generate a picture it fails, showing the error above.

Sysinfo

Windows 11 Nvidia RTX 4070ti Automatic1111 sysinfo-2023-10-17-11-56.txt

Relevant console log

venv "C:\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Version: v1.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
current transparent-background 1.2.4
Checking ReActor requirements... Ok
Launching Web UI with arguments: --administrator --xformers --port 4269 --api --no-half-vae --medvram-sdxl
Civitai Helper: Get Custom Model Folder
Additional Network extension not installed, Only hijack built-in lora
LoCon Extension hijack built-in lora successfully
[-] ADetailer initialized. version: 23.10.1, num models: 9
[AddNet] Updating model hashes...
0it [00:00, ?it/s]
[AddNet] Updating model hashes...
0it [00:00, ?it/s]
2023-10-17 14:51:06,416 - ControlNet - INFO - ControlNet v1.1.411
ControlNet preprocessor location: C:\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads
2023-10-17 14:51:06,503 - ControlNet - INFO - ControlNet v1.1.411
Loading FABRIC v0.6.3
14:51:06 - ReActor - STATUS - Running v0.4.3-b1
Loading weights [879db523c3] from C:\stable-diffusion-webui\models\Stable-diffusion\dreamshaper_8.safetensors
Creating model from config: C:\stable-diffusion-webui\configs\v1-inference.yaml
[CozyNest:INFO] version: 2.4.4 on auto1111
[Cozy:ImageBrowser:INFO] CozyNestSocket: Starting socket server on localhost:3333...
Civitai Helper: Settings:
Civitai Helper: max_size_preview: True
Civitai Helper: skip_nsfw_preview: False
Civitai Helper: open_url_with_js: True
Civitai Helper: proxy:
[VRAMEstimator] Loaded benchmark data.
*Deforum ControlNet support: enabled*
Loading VAE weights specified in settings: C:\stable-diffusion-webui\models\VAE\vae-ft-mse-840000-ema-pruned.ckpt
Running on local URL:  http://127.0.0.1:4269

To create a public link, set `share=True` in `launch()`.
Startup time: 19.1s (prepare environment: 6.9s, import torch: 2.1s, import gradio: 0.8s, setup paths: 0.4s, initialize shared: 0.2s, other imports: 0.4s, load scripts: 3.6s, reload hypernetworks: 0.1s, create ui: 4.2s, gradio launch: 0.3s).
Applying attention optimization: xformers... done.
Model loaded in 7.3s (load weights from disk: 0.4s, create model: 0.2s, apply weights to model: 2.8s, apply dtype to VAE: 0.9s, load VAE: 0.4s, calculate empty prompt: 2.4s).
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:01<00:00, 16.17it/s]
14:52:39 - ReActor - STATUS - Working: source face index [0], target face index [0]████| 20/20 [00:00<00:00, 19.44it/s]
14:52:39 - ReActor - STATUS - Analyzing Source Image...
14:52:40 - ReActor - STATUS - Analyzing Target Image...
14:52:41 - ReActor - STATUS - Detecting Source Face, Index = 0
14:52:41 - ReActor - STATUS - Detected: -29- y.o. Female
*** Error running postprocess_image: C:\stable-diffusion-webui\extensions\sd-webui-reactor\scripts\reactor_faceswap.py
    Traceback (most recent call last):
      File "C:\stable-diffusion-webui\modules\scripts.py", line 675, in postprocess_image
        script.postprocess_image(p, pp, *script_args)
      File "C:\stable-diffusion-webui\extensions\sd-webui-reactor\scripts\reactor_faceswap.py", line 376, in postprocess_image
        result, output, swapped = swap_face(
      File "C:\stable-diffusion-webui\extensions\sd-webui-reactor\scripts\reactor_swapper.py", line 320, in swap_face
        face_swapper = getFaceSwapModel(model)
      File "C:\stable-diffusion-webui\extensions\sd-webui-reactor\scripts\reactor_swapper.py", line 89, in getFaceSwapModel
        FS_MODEL = insightface.model_zoo.get_model(model_path, providers=providers)
      File "C:\stable-diffusion-webui\venv\lib\site-packages\insightface\model_zoo\model_zoo.py", line 96, in get_model
        model = router.get_model(providers=providers, provider_options=provider_options)
      File "C:\stable-diffusion-webui\extensions\sd-webui-reactor\scripts\console_log_patch.py", line 21, in patched_get_model
        session = PickableInferenceSession(self.onnx_file, **kwargs)
      File "C:\stable-diffusion-webui\venv\lib\site-packages\insightface\model_zoo\model_zoo.py", line 25, in __init__
        super().__init__(model_path, **kwargs)
      File "C:\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 383, in __init__
        self._create_inference_session(providers, provider_options, disabled_optimizers)
      File "C:\stable-diffusion-webui\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 424, in _create_inference_session
        sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
    onnxruntime.capi.onnxruntime_pybind11_state.InvalidProtobuf: [ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model from C:\stable-diffusion-webui\models\insightface\inswapper_128.onnx failed:Protobuf parsing failed.

---
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:04<00:00,  4.74it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:04<00:00, 19.44it/s]

Additional information

No response

Gourieff commented 10 months ago

Try this (Sec. V) https://github.com/Gourieff/sd-webui-reactor#v-invalid_protobuf--load-model-from-modelsinsightfaceinswapper_128onnx-failedprotobuf-parsing-failed-or-attributeerror-nonetype-object-has-no-attribute-get-or-attributeerror-faceswapscript-object-has-no-attribute-save_original

gharmonica commented 10 months ago

This fixed it, for some reason I had 2 models in the insightface folder, one of the broken model and another inside another folder of the good model.