hacksider / Deep-Live-Cam

real time face swap and one-click video deepfake with only a single image
GNU Affero General Public License v3.0
34.85k stars 4.91k forks source link

onxxruntime - InvalidProtobuf #150

Open StayFoolisj opened 1 month ago

StayFoolisj commented 1 month ago

Hey

I'm on MacOS M1 with arm64 and everything installs okay, but when I try to run live mode with all settings default and an image uploaded, I get the following error. I'm on the experiemental branch: https://github.com/hacksider/Deep-Live-Cam/commit/8d3072d906a24c8410abc5b52c9181036cfd4f70. I followed the insctructions and installed nnxruntime-silicon==1.13.1

python run.py
Frame processor face_enhancer not found
Frame processor face_enhancer not found
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: /Users/some_user/.insightface/models/buffalo_l/1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: /Users/some_user/.insightface/models/buffalo_l/2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: /Users/some_user/.insightface/models/buffalo_l/det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: /Users/some_user/.insightface/models/buffalo_l/genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0
Exception in Tkinter callback
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/.venv/lib/python3.10/site-packages/customtkinter/windows/widgets/ctk_button.py", line 554, in _clicked
    self._command()
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/modules/ui.py", line 104, in <lambda>
    live_button = ctk.CTkButton(root, text='Live', cursor='hand2', command=lambda: webcam_preview())
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/modules/ui.py", line 281, in webcam_preview
    source_image = get_one_face(cv2.imread(modules.globals.source_path))
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/modules/face_analyser.py", line 20, in get_one_face
    face = get_face_analyser().get(frame)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/modules/face_analyser.py", line 14, in get_face_analyser
    FACE_ANALYSER = insightface.app.FaceAnalysis(name='buffalo_l', providers=modules.globals.execution_providers)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/.venv/lib/python3.10/site-packages/insightface/app/face_analysis.py", line 31, in __init__
    model = model_zoo.get_model(onnx_file, **kwargs)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/.venv/lib/python3.10/site-packages/insightface/model_zoo/model_zoo.py", line 96, in get_model
    model = router.get_model(providers=providers, provider_options=provider_options)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/.venv/lib/python3.10/site-packages/insightface/model_zoo/model_zoo.py", line 40, in get_model
    session = PickableInferenceSession(self.onnx_file, **kwargs)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/.venv/lib/python3.10/site-packages/insightface/model_zoo/model_zoo.py", line 25, in __init__
    super().__init__(model_path, **kwargs)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/.venv/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 347, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "/Users/some_user/Desktop/code/Deep-Live-Cam/.venv/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 384, 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 /Users/some_user/.insightface/models/buffalo_l/w600k_r50.onnx failed:Protobuf parsing failed.
vessenes commented 1 month ago

If you inspect w600k_r50.onnx you will find that it's a downloaded HTML file, I bet. Some of the download links seem to be incorrect, or possibly require that you have huggingface access from python. Not a dev here, just dealt with this ten minutes ago :)

meirm commented 1 month ago

[ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model from .../git/github/Deep-Live-Cam/models/inswapper_128_fp16.onnx failed:Protobuf parsing failed.

I logged in using huggingface-cli login deleted the models directory and it is still downloading the HTML

Workaround: download inswapper_128.onnx from huggingface and replace the original inswapper_128_fp16.onnx with it

RockyMountainEagleEye commented 1 month ago

Same issue: Running Mac SiliconM3- : 7 : INVALID_PROTOBUF : Load model from /Users/x/Deep-Live-Cam/models/inswapper_128_fp16.onnx failed:Protobuf parsing failed.

MacBook-Pro ~ % pip install onnxruntime-silicon==1.13.1 ERROR: Could not find a version that satisfies the requirement onnxruntime-silicon==1.13.1 (from versions: none) ERROR: No matching distribution found for onnxruntime-silicon==1.13.1

Not sure what I'm doing wrong here.

petersolimine commented 1 month ago

Same issue here, @meirm I am trying this solution now

petersolimine commented 1 month ago

No luck, still running into the following:

onnxruntime.capi.onnxruntime_pybind11_state.InvalidProtobuf: [ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model from /Users/petersolimine/.insightface/models/buffalo_l/w600k_r50.onnx failed:Protobuf parsing failed.

and/or

ERROR: Could not find a version that satisfies the requirement onnxruntime-silicon==1.13.1 (from versions: none) ERROR: No matching distribution found for onnxruntime-silicon==1.13.1

xinyiliu128 commented 1 month ago

download the model from inswapper_128_fp16.onnx and replace it with the original model.

source: https://huggingface.co/ZiqianLiu/yolov8_face

StayFoolisj commented 1 month ago

Same issue: Running Mac SiliconM3- : 7 : INVALID_PROTOBUF : Load model from /Users/x/Deep-Live-Cam/models/inswapper_128_fp16.onnx failed:Protobuf parsing failed.

MacBook-Pro ~ % pip install onnxruntime-silicon==1.13.1 ERROR: Could not find a version that satisfies the requirement onnxruntime-silicon==1.13.1 (from versions: none) ERROR: No matching distribution found for onnxruntime-silicon==1.13.1

Not sure what I'm doing wrong here.

Make sure you are using python3.10. You can install Python versions using pyenv

A problem I had earlier was that my python interpreter was using the arch x86, probably due to rosetta. If your python interpreter is called python3.10 then try this command:

python3.10 -c "import platform; print(platform.machine())"

If it doesn't print arm64, you need to reinstall Python. If you install it via brew it might be worth to check if brew is installed using rosetta which could be the root problem to why your python intepreter is using the wrong arch

meirm commented 1 month ago

I didn't follow the versions indicated in the requirements.txt and installed onnxruntime-silicon==1.16.3

quanljh commented 1 month ago

I got this error because I put those 2 models into "modules" folder while the correct is "models".

petersolimine commented 1 month ago

@meirm valid, but I am unable to install the specified version on my Mac.

MacBook-Pro ~ % pip install onnxruntime-silicon==1.13.1 ERROR: Could not find a version that satisfies the requirement onnxruntime-silicon==1.13.1 (from versions: none) ERROR: No matching distribution found for onnxruntime-silicon==1.13.1

Also, can confirm my models are in "models" 😄

mhelbich commented 1 month ago

Same situation for me apparently

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "C:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 554, in _clicked
    self._command()
  File "C:\Users\Matze\Documents\Code\Deep-Live-Cam\modules\ui.py", line 95, in <lambda>
    start_button = ctk.CTkButton(root, text='Start', cursor='hand2', command=lambda: select_output_path(start))
  File "C:\Users\Matze\Documents\Code\Deep-Live-Cam\modules\ui.py", line 192, in select_output_path
    start()
  File "C:\Users\Matze\Documents\Code\Deep-Live-Cam\modules\core.py", line 171, in start
    if not frame_processor.pre_start():
  File "C:\Users\Matze\Documents\Code\Deep-Live-Cam\modules\processors\frame\face_swapper.py", line 28, in pre_start
    elif not get_one_face(cv2.imread(modules.globals.source_path)):
  File "C:\Users\Matze\Documents\Code\Deep-Live-Cam\modules\face_analyser.py", line 20, in get_one_face
    face = get_face_analyser().get(frame)
  File "C:\Users\Matze\Documents\Code\Deep-Live-Cam\modules\face_analyser.py", line 14, in get_face_analyser
    FACE_ANALYSER = insightface.app.FaceAnalysis(name='buffalo_l', providers=modules.globals.execution_providers)
  File "C:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\lib\site-packages\insightface\app\face_analysis.py", line 31, in __init__
    model = model_zoo.get_model(onnx_file, **kwargs)
  File "C:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\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:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\lib\site-packages\insightface\model_zoo\model_zoo.py", line 40, in get_model
    session = PickableInferenceSession(self.onnx_file, **kwargs)
  File "C:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\lib\site-packages\insightface\model_zoo\model_zoo.py", line 25, in __init__
    super().__init__(model_path, **kwargs)
  File "C:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 383, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "C:\Users\Matze\.pyenv\pyenv-win\versions\3.10.0\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:\Users\Matze/.insightface\models\buffalo_l\w600k_r50.onnx failed:Protobuf parsing failed.

Windows 10, using pyenv (3.10.0). Followed the installation pretty precisely - not quite sure where to attempt to fix.