pozitronik / sinner

Sinner: Sinner Is NoN Exactly Roop
GNU Affero General Public License v3.0
74 stars 9 forks source link

BUG: Parameter --execution_provider=['gpu'] in module FaceSwapper is not in ['cpu'] #87

Open alexjolig opened 11 months ago

alexjolig commented 11 months ago

Describe the bug Everytime I try to choose a different execution provider, I face this error: LoadingException: Parameter --execution_provider=['gpu'] in module FaceSwapper is not in ['cpu']

To Reproduce Steps to reproduce the behavior:

python sin.py --source="cool_photo.jpg" --target="not_a_porn.mp4" --frame-processor FaceSwapper FaceEnhancer --output="result.mp4" --many-faces --execution-provider=cuda

If I choose cuda or gpu I'll face this error

Here's the full stack trace:

Traceback (most recent call last):
  File "projects/sinner/sin.py", line 55, in <module>
    Sin().run()
  File "projects/sinner/sin.py", line 46, in run
    BatchProcessingCore(parameters=self.parameters).run()
  File "projects/sinner/sinner/BatchProcessingCore.py", line 110, in run
    current_processor = BaseFrameProcessor.create(processor_name, self.parameters)
  File "projects/sinner/sinner/processors/frame/BaseFrameProcessor.py", line 26, in create
    return handler_class(**params)
  File "projects/sinner/sinner/processors/frame/FaceSwapper.py", line 97, in __init__
    super().__init__(parameters)
  File "projects/sinner/sinner/processors/frame/BaseFrameProcessor.py", line 49, in __init__
    super().__init__(self.parameters)
  File "projects/sinner/sinner/validators/AttributeLoader.py", line 60, in __init__
    raise LoadingException(self.errors)
sinner.validators.LoaderException.LoadingException: Parameter --execution_provider=['gpu'] in module FaceSwapper is not in ['cpu']

Sanity Check

pozitronik commented 11 months ago

It is not an error. This message means that your current hardware/software configuration supports only the 'cpu' execution provider for onnx runtime.

alexjolig commented 11 months ago

@pozitronik So is there something I can do or it's just what it is?

pozitronik commented 11 months ago

I'll try to explain it as much, as I understand it myself. There's ONNX Runtime, a framework that can run AI models on different types of providers; you can read there about. You've installed the ONNX Runtime package that supports only the CpuProvider on your hardware (which utilizes the CPU, obviously). I suppose you have to find and install the onnxruntime-silicon package, which may support some kind of hardware acceleration. It seems that onnxruntime-silicon builds can be found there. I would appreciate it if you could try to check on this; I can't do it myself, as there's no Mac nearby.

alexjolig commented 11 months ago

@pozitronik Thanks for the explanation. I'd definitely try it and let you know how it goes.

alexjolig commented 11 months ago

Maybe not the right thread, but just wanted to mention that since installing pyvirtualcam is not supported for Mac M1/M2, the work around is to install it from source:

pip install git+https://github.com/letmaik/pyvirtualcam

One other thing that can help is that you replace it in requirements by this:

git+https://github.com/letmaik/pyvirtualcam; platform_system == "Darwin" and platform.machine == "arm64" pyvirtualcam; platform_system != "Darwin" or platform.machine != "arm64"

I tested those solutions and they worked for me.

Maybe you can add Apple silicon hints to your README file.

pozitronik commented 11 months ago

Maybe you can add Apple silicon hints to your README file.

Thanks, i definitely will do that.