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

15 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...

john said...

mine will run very fainty with this write up , i need need
C:\Windows\System32\Deep-Live-Cam>python run.py --execution-provider cuda --execution-threads 60 --max-memory 60
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "C:\Program Files\Python310\lib\tkinter\__init__.py", line 839, in callit
func(*args)
File "C:\Users\HP OMEN\AppData\Roaming\Python\Python310\site-packages\customtkinter\windows\widgets\scaling\scaling_tracker.py", line 186, in check_dpi_scaling
window.block_update_dimensions_event()
File "C:\Program Files\Python310\lib\tkinter\__init__.py", line 2383, in __getattr__
return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'block_update_dimensions_event'

NELLY said...

As a run the git clone https://github.com/hacksider/Deep-Live-Cam.git, i was not able to see the file on my PC , in other to save other file on it

Kojo said...

My DeepLiveCam software opens fine, but the camera isn't working with it. I've enabled it through Terminal and it's working fine with other apps like FaceTime. The issue is that DeepLiveCam isn't recognizing the camera even though its working. The error i always receive is
Camera is accessible
OpenCV: out device of bound (0-0): 1
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 2
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 3
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 4
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 5
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 6
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 7
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 8
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 9
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 10
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 11
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 12
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 13
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 14
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 15
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 16
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 17
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 18
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 19
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 20
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 21
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 22
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 23
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 24
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 25
OpenCV: camera failed to properly initialize!
OpenCV: out device of bound (0-0): 26-99

OpenCV: camera failed to properly initialize!



ive been on this for almost a week. Please help.

Kojo said...

Install OpenCV: Open a terminal or command prompt and run:


pip install opencv-python

This will install the basic OpenCV package.

Install Full OpenCV (Optional): If you need additional functionality like non-free algorithms (e.g., face detection), you might want to install the full package:


pip install opencv-contrib-python

Verify Installation: After installation, you can verify that OpenCV is installed correctly by running this in your Python interpreter:

open python and run this or just copy and past

import cv2
print(cv2.__version__)

This should print the version of OpenCV installed, confirming the module is available.

After this, you should be able to run your script without encountering the ModuleNotFoundError. Let me know if you run into any other issues!