GithubHelp home page GithubHelp logo

hacksider / deep-live-cam Goto Github PK

View Code? Open in Web Editor NEW
139.0 2.0 24.0 37.61 MB

real time face swap and one-click video deepfake with only a single image (uncensored)

License: GNU Affero General Public License v3.0

Python 98.70% Batchfile 1.30%
ai-face deepfake video-deepfake deepfake-webcam fake-webcam realtime-deepfake realtime-face-changer faceswap webcam ai-deep-fake

deep-live-cam's Introduction

demo-gif

Disclaimer

This software is meant to be a productive contribution to the rapidly growing AI-generated media industry. It will help artists with tasks such as animating a custom character or using the character as a model for clothing etc.

The developers of this software are aware of its possible unethical applicaitons and are committed to take preventative measures against them. It has a built-in check which prevents the program from working on inappropriate media including but not limited to nudity, graphic content, sensitive material such as war footage etc. We will continue to develop this project in the positive direction while adhering to law and ethics. This project may be shut down or include watermarks on the output if requested by law.

Users of this software are expected to use this software responsibly while abiding the local law. If face of a real person is being used, users are suggested to get consent from the concerned person and clearly mention that it is a deepfake when posting content online. Developers of this software will not be responsible for actions of end-users.

How do I install it?

Basic: It is more likely to work on your computer but it will also be very slow. You can follow instructions for the basic install (This usually runs via CPU)

1.Setup your platform

2. Clone Repository

https://github.com/hacksider/Deep-Live-Cam.git

3. Download Models

  1. GFPGANv1.4
  2. inswapper_128_fp16.onnx

Then put those 2 files on the "models" folder

4. Install dependency

We highly recommend to work with a venv to avoid issues.

pip install -r requirements.txt
DONE!!! If you dont have any GPU, You should be able to run roop using python run.py command. Keep in mind that while running the program for first time, it will download some models which can take time depending on your network connection.

*Proceed if you want to use GPU Acceleration

CUDA Execution Provider (Nvidia)*

  1. Install CUDA Toolkit 11.8

  2. Install dependencies:

pip uninstall onnxruntime onnxruntime-gpu
pip install onnxruntime-gpu==1.15.1

  1. Usage in case the provider is available:
python run.py --execution-provider cuda

CoreML Execution Provider (Apple Silicon)

  1. Install dependencies:
pip uninstall onnxruntime onnxruntime-silicon
pip install onnxruntime-silicon==1.13.1

  1. Usage in case the provider is available:
python run.py --execution-provider coreml

CoreML Execution Provider (Apple Legacy)

  1. Install dependencies:
pip uninstall onnxruntime onnxruntime-coreml
pip install onnxruntime-coreml==1.13.1

  1. Usage in case the provider is available:
python run.py --execution-provider coreml

DirectML Execution Provider (Windows)

  1. Install dependencies:
pip uninstall onnxruntime onnxruntime-directml
pip install onnxruntime-directml==1.15.1

  1. Usage in case the provider is available:
python run.py --execution-provider directml

OpenVINO™ Execution Provider (Intel)

  1. Install dependencies:
pip uninstall onnxruntime onnxruntime-openvino
pip install onnxruntime-openvino==1.15.0

  1. Usage in case the provider is available:
python run.py --execution-provider openvino

How do I use it?

Note: When you run this program for the first time, it will download some models ~300MB in size.

Executing python run.py command will launch this window: gui-demo

Choose a face (image with desired face) and the target image/video (image/video in which you want to replace the face) and click on Start. Open file explorer and navigate to the directory you select your output to be in. You will find a directory named <video_title> where you can see the frames being swapped in realtime. Once the processing is done, it will create the output file. That's it.

For the webcam mode

Just follow the clicks on the screenshot

  1. Select a face
  2. Click live
  3. Wait for a few second (it takes a longer time, usually 10 to 30 seconds before the preview shows up)

demo-gif

Just use your favorite screencapture to stream like OBS

Note: In case you want to change your face, just select another picture, the preview mode will then restart (so just wait a bit).

Additional command line arguments are given below. To learn out what they do, check this guide.

options:
  -h, --help                                               show this help message and exit
  -s SOURCE_PATH, --source SOURCE_PATH                     select an source image
  -t TARGET_PATH, --target TARGET_PATH                     select an target image or video
  -o OUTPUT_PATH, --output OUTPUT_PATH                     select output file or directory
  --frame-processor FRAME_PROCESSOR [FRAME_PROCESSOR ...]  frame processors (choices: face_swapper, face_enhancer, ...)
  --keep-fps                                               keep original fps
  --keep-audio                                             keep original audio
  --keep-frames                                            keep temporary frames
  --many-faces                                             process every face
  --video-encoder {libx264,libx265,libvpx-vp9}             adjust output video encoder
  --video-quality [0-51]                                   adjust output video quality
  --max-memory MAX_MEMORY                                  maximum amount of RAM in GB
  --execution-provider {cpu} [{cpu} ...]                   available execution provider (choices: cpu, ...)
  --execution-threads EXECUTION_THREADS                    number of execution threads
  -v, --version                                            show program's version number and exit

Looking for a CLI mode? Using the -s/--source argument will make the run program in cli mode.

Credits

  • henryruhs: for being an irreplaceable contributor to the project
  • ffmpeg: for making video related operations easy
  • deepinsight: for their insightface project which provided a well-made library and models.
  • havok2-htwo : for sharing the code for webcam
  • GosuDRM : for uncensoring roop
  • and all developers behind libraries used in this project.

deep-live-cam's People

Contributors

hacksider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

deep-live-cam's Issues

AttributeError: 'NoneType' object has no attribute 'shape'

File "C:\Users\user1\Downloads\Deep-Live-Cam-main\Deep-Live-Cam-main\modules\face_analyser.py", line 20, in get_one_face
face = get_face_analyser().get(frame)
File "C:\Users\user1\anaconda3\lib\site-packages\insightface\app\face_analysis.py", line 59, in get
bboxes, kpss = self.det_model.detect(img,
File "C:\Users\user1\anaconda3\lib\site-packages\insightface\model_zoo\retinaface.py", line 211, in detect
im_ratio = float(img.shape[0]) / img.shape[1]
AttributeError: 'NoneType' object has no attribute 'shape'

Camera is on (camera light is on)

A small little window opens up, after starting live

Protobuf parsing failed - model fails

The inswapper_128_fp16.onnx model is invalid. This can be checked with

import onnx
onnx_model = onnx.load("inswapper_128_fp16.onnx")
onnx.checker.check_model(onnx_model)

I solved this by adjusting faceswapper.py and just using the standard inswapper_128.onnx model here

Petition: Opacity slider

Your aplication is Awesome. Could you include a Slider with the opacity from 0 to 100 in the face, like in Deepfacelive?. And if is posible to mantain the original colors from the original photo instead to adapt the colors in the target. In photos with makeup don´t take the makeup from the original photo.
Sorry for my english, i´m not native.

Trouble with installing in MacOS

Hello @hacksider

I'm installing this App on my Macbook and have issues with installing GPU libraries (onnxruntime). Tried installing dependencies for CoreML Execution Provider (Apple Legacy) and got this error message:

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

Platform:
CPU: 6-Core Intel Core i7
Firmware Date: 2020
2 GPUs:
1. AMD Radeon Pro 5300M (PCIe)
2. Intel UHD Graphics 630 (built-in)

Please let me know the solution for running the App via GPU.

Thanks

Run faster

Can you put it in a google collab, so it can run faster

Can´t find "models" folder

Step 3. "Then put those 2 files on the "models" folder"

Downloaded the 2 files, but could not find the "models" folder

Is it in the repo?

Face Enhancer

For the face_enhancer.py GAN model to work change the \ to / on the model import

openvino not working

(base) (venv) C:\Users\DELL\Deep-Live-Cam>python run.py --execution-provider openvino
usage: run.py [-h] [-s SOURCE_PATH] [-t TARGET_PATH] [-o OUTPUT_PATH]
[--frame-processor {face_swapper,face_enhancer} [{face_swapper,face_enhancer} ...]] [--keep-fps] [--keep-audio] [--keep-frames]
[--many-faces] [--video-encoder {libx264,libx265,libvpx-vp9}] [--video-quality [0-51]] [--max-memory MAX_MEMORY]
[--execution-provider {azure,cpu} [{azure,cpu} ...]] [--execution-threads EXECUTION_THREADS] [-v]
run.py: error: argument --execution-provider: invalid choice: 'openvino' (choose from 'azure', 'cpu')

Preview show nothing

Hi,
First thanks for you project.
I select a face then click live a popup show preview but there is nothing on it as you can see below. My webcam is working as i have tested it. Could you help me to resolve it ?

Capture

Face enhacement Lower FPS

I´m using your repository with GPU. I have Nvidia geforce RTX 3070 with cuda installed.
The software is working great but when i use face enhacement, is awesome, lowers the FPS and is isposible to use. Any tips to avoid lowering FPS when using face enhacement?
Thanks in advance

Freezing issues

Hello mine is running but freezing on RTX3060 16gb dedicated, please how can I fix it and also how can I make display very clear and efficient.

thanks

Can't get virtual cameras as input

I'm trying to use a virtual camera (OBS, Nvidia Broadcast...) as an input to Deep-Live-Cam. Not even getting an error that I could share here, it just freezes. I've tried to change the camera index on the code with no luck, on one of them I got som RGB weird noise and I'm looking into possibly transcoding the image to try again. But it would be awesome to have a camera selector in the GUI.

error pls help me

(deeplivecam) C:\WINDOWS\system32>python run.py --execution-provider cuda
python: can't open file 'C:\WINDOWS\system32\run.py': [Errno 2] No such file or directory

NoneType' object has no attribute 'configure'

File "C:\Users\user1\Downloads\Deep-Live-Cam-main\Deep-Live-Cam-main\modules\ui.py", line 137, in update_status
status_label.configure(text=text)
AttributeError: 'NoneType' object has no attribute 'configure'

get this error message when starting the programm

Nothing happens

The application doesn't run after running the start command. Can any anybody help ? I've done everything right but after the python run.py ----execution-provider cuda nothing happens the app doesn't get started

Doesn't work on macOS on M1 Pro

I'm using MacBook Pro M1 Pro on macOS Sonoma 14.3.1 (23D60). Installed as stated in manual.

launched with a command
python run.py --execution-provider coreml

Chose an image
image

When I'm trying to run LIVE, I get that error and black preview window:
python run.py --execution-provider coreml Applied providers: ['CoreMLExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CoreMLExecutionProvider': {}} find model: /Users/rouol/.insightface/models/buffalo_l/1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0 Applied providers: ['CoreMLExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CoreMLExecutionProvider': {}} find model: /Users/rouol/.insightface/models/buffalo_l/2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0 Applied providers: ['CoreMLExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CoreMLExecutionProvider': {}} find model: /Users/rouol/.insightface/models/buffalo_l/det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0 Applied providers: ['CoreMLExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CoreMLExecutionProvider': {}} find model: /Users/rouol/.insightface/models/buffalo_l/genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0 Applied providers: ['CoreMLExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CoreMLExecutionProvider': {}} find model: /Users/rouol/.insightface/models/buffalo_l/w600k_r50.onnx recognition ['None', 3, 112, 112] 127.5 127.5 set det-size: (640, 640) Applied providers: ['CoreMLExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CoreMLExecutionProvider': {}} inswapper-shape: [1, 3, 128, 128] Exception in Tkinter callback Traceback (most recent call last): File "/opt/homebrew/Caskroom/miniconda/base/envs/py310tf/lib/python3.10/tkinter/__init__.py", line 1921, in __call__ return self.func(*args) File "/Users/rouol/Code/WORK/Deep-Live-Cam/venv/lib/python3.10/site-packages/customtkinter/windows/widgets/ctk_button.py", line 553, in _clicked self._command() File "/Users/rouol/Code/WORK/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/rouol/Code/WORK/Deep-Live-Cam/modules/ui.py", line 286, in webcam_preview temp_frame = frame_processor.process_frame(source_image, temp_frame) File "/Users/rouol/Code/WORK/Deep-Live-Cam/modules/processors/frame/face_swapper.py", line 60, in process_frame temp_frame = swap_face(source_face, target_face, temp_frame) File "/Users/rouol/Code/WORK/Deep-Live-Cam/modules/processors/frame/face_swapper.py", line 48, in swap_face return get_face_swapper().get(temp_frame, target_face, source_face, paste_back=True) File "/Users/rouol/Code/WORK/Deep-Live-Cam/venv/lib/python3.10/site-packages/insightface/model_zoo/inswapper.py", line 50, in get latent = source_face.normed_embedding.reshape((1,-1)) AttributeError: 'NoneType' object has no attribute 'normed_embedding'

image

Dont starting

Hello, I installed the program as written in the instructions, but ultimately the program starts, it says "WARNING:tensorflow:From C:\Users\Max\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\ losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.", then two empty lines and stops working after a few seconds. What should I do? I have Windows 10 and I installed python 3.10.6, pip, git, ffmpeg, visual studio 2022 runtimes and downloaded the models, created a models folder and added them there.

image

color tranfer

can you please make the color of the picture transfer to the face during LIVE?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.