Friday, August 9, 2024

Deep Live Cam Local Installation Easy Guide for Face Swap and Deepfake Video on Webcam

 This is step-by-step easy tutorial to install Deep Live Cam for real time face swap and one-click video deepfake with only a single image (uncensored) locally on Windows.


Code:


1- Install Choco

Open Powershell as Administrator and run following:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

2- Install following pre-reqs

choco install python --version=3.10.0
choco install git
choco install ffmpeg

3- Install Visual Studio from https://visualstudio.microsoft.com/visual-cpp-build-tools/

3- git clone https://github.com/hacksider/Deep-Live-Cam.git and cd Deep-Live-Cam

4- Download 2 models from https://huggingface.co/hacksider/deep-live-cam/tree/main and put it in Deep-Live-Cam\models folder

5- cd Deep-Live-Cam and pip install -r requirements.txt

6- If on CPU, run python run.py

For GPU:

7- Install CUDA Toolkit 11.8 from https://developer.nvidia.com/cuda-11-8-0-download-archive

8- Install dependencies:

pip uninstall onnxruntime onnxruntime-gpu
pip install onnxruntime-gpu==1.16.3

9-  python run.py --execution-provider cuda

Enjoy

11 comments:

traxmeister said...

PS C:\Windows\system32\Deep-Live-Cam> python run.py --execution-provider cuda
Traceback (most recent call last):
File "C:\Windows\system32\Deep-Live-Cam\run.py", line 3, in
from modules import core
File "C:\Windows\system32\Deep-Live-Cam\modules\core.py", line 14, in
import torch
ModuleNotFoundError: No module named 'torch'
What should I do?

NABOO MAN said...

install torch bro : pip install torch

xd Joliss said...

got this problem, saying something about not being on the right windows version. im on windows 11

C:\Python312\Lib\site-packages\onnxruntime\capi\onnxruntime_validation.py:26: UserWarning: Unsupported Windows version (11). ONNX Runtime supports Windows 10 and above, only.
warnings.warn(
Traceback (most recent call last):
File "C:\windows\system32\Deep-Live-Cam\run.py", line 3, in
from modules import core
File "C:\windows\system32\Deep-Live-Cam\modules\core.py", line 20, in
import modules.ui as ui
File "C:\windows\system32\Deep-Live-Cam\modules\ui.py", line 5, in
import cv2
ModuleNotFoundError: No module named 'cv2'

jay said...

Please help ,i did everything to the very last end and when i run python run.py --execution-provider cuda , then i get this error .

Traceback (most recent call last):
File "run.py", line 3, in
from modules import core
File "C:\Windows\system32\Deep-Live-Cam\modules\core.py", line 20, in
import modules.ui as ui
File "C:\Windows\system32\Deep-Live-Cam\modules\ui.py", line 10, in
from modules.face_analyser import get_one_face
File "C:\Windows\system32\Deep-Live-Cam\modules\face_analyser.py", line 5, in
from modules.typing import Frame
File "C:\Windows\system32\Deep-Live-Cam\modules\typing.py", line 7, in
Frame = numpy.ndarray[Any, Any]
TypeError: Type subscription requires python >= 3.9

dght said...

Traceback (most recent call last):
File "C:\Windows\system32\Deep-Live-Cam\run.py", line 3, in
from modules import core
File "C:\Windows\system32\Deep-Live-Cam\modules\core.py", line 14, in
import torch
File "C:\Python310\lib\site-packages\torch\__init__.py", line 148, in
raise err
OSError: [WinError 126] Le module spécifié est introuvable. Error loading "C:\Python310\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

Unknown said...

You can not use System32. That is the default path power shell uses. You will need to switch the path to something like C: or C:\whatevs then it should work. If you get an error about: ERROR: Failed building wheel for insightface
make sure you install: In visual studio, you choose to modify, Select: Workloads → Desktop development with C++

Daniel said...

Tutorial doesn't work. Not detailed enough.
Getting multiple errors, now stuck at: ModuleNotFoundError: No module named 'cv2'

energymck said...

i got following message after trying to do the live function in my power shell:

[ WARN:2@405.181] global cap_msmf.cpp:471 `anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772
[ WARN:2@405.184] global cap_msmf.cpp:483 `anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:1@405.187] global cap_msmf.cpp:1759 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772

ultraop said...

PS H:\New folder (9)\Deep-Live-Cam-main\Deep-Live-Cam-main\Deep-Live-Cam> python run.py --execution-provider cuda
Traceback (most recent call last):
File "H:\New folder (9)\Deep-Live-Cam-main\Deep-Live-Cam-main\Deep-Live-Cam\run.py", line 3, in
from modules import core
File "H:\New folder (9)\Deep-Live-Cam-main\Deep-Live-Cam-main\Deep-Live-Cam\modules\core.py", line 14, in
import torch
File "C:\Python310\lib\site-packages\torch\__init__.py", line 148, in
raise err
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Python310\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

MagicMan666 said...

follow the video and working - just fantastic work!!

Black magic said...

I did all but when i run the softwares it gives this error

Traceback (most recent call last):
File "C:\Python310\lib\tkinter\__init__.py", line 1921, in call
return self.func(*args)
File "C:\Python310\lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 554, in _clicked
self._command()
File "C:\users\horus\deep-live-cam\modules\ui.py", line 97, in
start_button = ctk.CTkButton(root, text='Start', cursor='hand2', command=lambda: select_output_path(start))
File "C:\users\horus\deep-live-cam\modules\ui.py", line 194, in select_output_path
start()
File "C:\users\horus\deep-live-cam\modules\core.py", line 174, in start
if not frame_processor.pre_start():
File "C:\users\horus\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\horus\deep-live-cam\modules\face_analyser.py", line 20, in get_one_face
face = get_face_analyser().get(frame)
File "C:\users\horus\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:\Python310\lib\site-packages\insightface\app\face_analysis.py", line 27, in init
self.model_dir = ensure_available('models', name, root=root)
File "C:\Python310\lib\site-packages\insightface\utils\storage.py", line 28, in ensure_available
return download(sub_dir, name, force=False, root=root)
File "C:\Python310\lib\site-packages\insightface\utils\storage.py", line 17, in download
download_file(model_url,
File "C:\Python310\lib\site-packages\insightface\utils\download.py", line 71, in download_file
r = requests.get(url, stream=True)
File "C:\Python310\lib\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "C:\Python310\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python310\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python310\lib\site-packages\requests\sessions.py", line 724, in send
history = [resp for resp in gen]
File "C:\Python310\lib\site-packages\requests\sessions.py", line 724, in
history = [resp for resp in gen]
File "C:\Python310\lib\site-packages\requests\sessions.py", line 265, in resolve_redirects
resp = self.send(
File "C:\Python310\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "C:\Python310\lib\site-packages\requests\adapters.py", line 713, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='objects.githubusercontent.com', port=443): Read timed out. (read timeout=None)
PS C:\users\horus\deep-live-cam> python run.py --execution-provider cuda
download_path: C:\Users\horus/.insightface\models\buffalo_l
Downloading C:\Users\horus/.insightface\models\buffalo_l.zip from https://github.com/deepinsight/insightface/releases/download/v0.7/buffalo_l.zip...