{"id":636,"date":"2024-06-26T12:07:49","date_gmt":"2024-06-26T12:07:49","guid":{"rendered":"https:\/\/zahiralam.com\/blog\/?p=636"},"modified":"2024-10-01T09:03:25","modified_gmt":"2024-10-01T09:03:25","slug":"setting-up-facefusion-on-ubuntu-your-guide-to-ai-powered-face-swapping-and-deepfakes","status":"publish","type":"post","link":"https:\/\/zahiralam.com\/blog\/setting-up-facefusion-on-ubuntu-your-guide-to-ai-powered-face-swapping-and-deepfakes\/","title":{"rendered":"Setting Up FaceFusion on Ubuntu 24.04: Your Guide to AI-Powered Face Swapping and Deepfakes"},"content":{"rendered":"\n<p>FaceFusion is a powerful tool for facial recognition and analysis, often used for AI face swap applications, digital face replacement, and deepfake projects. Here\u2019s how to install it on Ubuntu, ensuring you utilize the best tools and libraries. FaceFusion can be used with just a CPU and does not require a GPU to operate.\n\n\n\n<p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ubuntu 18.04 or later<\/li>\n\n\n\n<li>Python 3.6 or later<\/li>\n\n\n\n<li>Optional : NVIDIA GPU with CUDA support (for GPU acceleration)<\/li>\n\n\n\n<li>At least 8GB of RAM<\/li>\n<\/ul>\n\n\n\n<p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Update and Upgrade Your System<\/h3>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-1\">sudo apt update\nsudo apt upgrade -y<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20update%0Asudo%20apt%20upgrade%20-y\">\n                            <button class=\"copy-button\" data-label=\"sudo apt update\nsudo apt upgrade -y\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install Essential Packages<\/h2>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-2\">sudo apt install -y build-essential cmake git-all curl python3 python3-pip python3-venv libopenblas-dev liblapack-dev libjpeg-dev libpng-dev ffmpeg mesa-va-drivers<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20install%20-y%20build-essential%20cmake%20git-all%20curl%20python3%20python3-pip%20python3-venv%20libopenblas-dev%20liblapack-dev%20libjpeg-dev%20libpng-dev%20ffmpeg%20mesa-va-drivers\">\n                            <button class=\"copy-button\" data-label=\"sudo apt install -y build-essential cmake git-all curl python3 python3-pip python3-venv libopenblas-dev liblapack-dev libjpeg-dev libpng-dev ffmpeg mesa-va-drivers\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Install Miniconda<\/h2>\n\n\n\n<p>Download and install either Miniconda or Anaconda to manage your Python environment. The article below provides detailed instructions on installing Miniconda.\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-zahirs-blog wp-block-embed-zahirs-blog\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"XQtUJVpjxD\"><a href=\"https:\/\/zahiralam.com\/blog\/conda-installation-on-ubuntu-simplified-step-by-step-instructions-with-activation-and-deactivation\/\">Conda Installation on Ubuntu: Simplified Step-by-Step Instructions with Activation and Deactivation<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Conda Installation on Ubuntu: Simplified Step-by-Step Instructions with Activation and Deactivation&#8221; &#8212; Zahirs Blog\" src=\"https:\/\/zahiralam.com\/blog\/conda-installation-on-ubuntu-simplified-step-by-step-instructions-with-activation-and-deactivation\/embed\/#?secret=ao6r3M8I5K#?secret=XQtUJVpjxD\" data-secret=\"XQtUJVpjxD\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Create and Activate Conda Environment<\/h2>\n\n\n\n<p>Create a dedicated Conda environment for FaceFusion to manage dependencies cleanly.\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-3\">conda create --name facefusion python=3.10\nconda activate facefusion<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20create%20--name%20facefusion%20python%3D3.10%0Aconda%20activate%20facefusion\">\n                            <button class=\"copy-button\" data-label=\"conda create --name facefusion python=3.10\nconda activate facefusion\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Install CUDA and cuDNN (Optional for GPU Acceleration)<\/h2>\n\n\n\n<p>For GPU acceleration, which significantly enhances performance in AI face swap and deepfake tasks:\n\n\n\n<p>Install CUDA Toolkit and cuDNN using Conda:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-4\">conda install conda-forge::cuda-toolkit=12.4.1 cudnn=8.9.2.26 conda-forge::gputil=1.4.0<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20install%20conda-forge%3A%3Acuda-toolkit%3D12.4.1%20cudnn%3D8.9.2.26%20conda-forge%3A%3Agputil%3D1.4.0\">\n                            <button class=\"copy-button\" data-label=\"conda install conda-forge::cuda-toolkit=12.4.1 cudnn=8.9.2.26 conda-forge::gputil=1.4.0\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Install OpenVINO (Optional for Intel Hardware Acceleration)<\/h2>\n\n\n\n<p>For those using Intel hardware, OpenVINO offers great optimization for AI workloads.\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-5\">conda install conda-forge::openvino=2023.1.0<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20install%20conda-forge%3A%3Aopenvino%3D2023.1.0\">\n                            <button class=\"copy-button\" data-label=\"conda install conda-forge::openvino=2023.1.0\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Clone FaceFusion Repository<\/h2>\n\n\n\n<p>FaceFusion\u2019s source code is available on GitHub. Clone the repository to get started.\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-6\">git clone https:\/\/github.com\/facefusion\/facefusion\ncd facefusion<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#git%20clone%20https%3A%2F%2Fgithub.com%2Ffacefusion%2Ffacefusion%0Acd%20facefusion\">\n                            <button class=\"copy-button\" data-label=\"git clone https:\/\/github.com\/facefusion\/facefusion\ncd facefusion\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8: Install FaceFusion<\/h2>\n\n\n\n<p>Run the installation script to set up FaceFusion.\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-7\">python install.py --onnxruntime &quot;default&quot;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python%20install.py%20--onnxruntime%20%22default%22\">\n                            <button class=\"copy-button\" data-label=\"python install.py --onnxruntime &quot;default&quot;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 9: Reload Conda Environment<\/h2>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-8\">conda deactivate<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20deactivate\">\n                            <button class=\"copy-button\" data-label=\"conda deactivate\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-9\">conda activate facefusion<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#conda%20activate%20facefusion\">\n                            <button class=\"copy-button\" data-label=\"conda activate facefusion\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 10: Run FaceFusion<\/h2>\n\n\n\n<p>Start FaceFusion to begin working with facial recognition and analysis.\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-10\">python facefusion.py run --open-browser<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python%20facefusion.py%20run%20--open-browser\">\n                            <button class=\"copy-button\" data-label=\"python facefusion.py run --open-browser\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 11: Verify Installation<\/h2>\n\n\n\n<p>Ensure that FaceFusion is installed correctly by checking its version.\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-11\">import facefusion\nprint(facefusion.__version__)<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#import%20facefusion%0Aprint%28facefusion.__version__%29\">\n                            <button class=\"copy-button\" data-label=\"import facefusion\nprint(facefusion.__version__)\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Additional Configuration<\/h3>\n\n\n\n<p>Refer to the <a href=\"https:\/\/docs.facefusion.io\/installation\" target=\"_blank\" rel=\"noreferrer noopener\">FaceFusion documentation<\/a> for detailed environment and accelerator setup, especially if you&#8217;re working with tools like Google Colab for remote processing or implementing NSFW filters.\n\n\n\n<p>\n\n\n\n<h3 class=\"wp-block-heading\">Troubleshooting<\/h3>\n\n\n\n<p>Consult the <a href=\"https:\/\/docs.facefusion.io\/installation\/platform\/linux\" target=\"_blank\" rel=\"noreferrer noopener\">Linux Installation Guide<\/a> and <a href=\"https:\/\/docs.facefusion.io\/installation\/environment\/linux\" target=\"_blank\" rel=\"noreferrer noopener\">Environment Setup Guide<\/a>. For GPU-related issues, refer to the <a href=\"https:\/\/docs.facefusion.io\/installation\/accelerator\/linux\" target=\"_blank\" rel=\"noreferrer noopener\">Accelerator Configuration Guide<\/a>.\n\n\n\n<p>For comprehensive instructions and troubleshooting, visit the official <a href=\"https:\/\/docs.facefusion.io\/installation\" target=\"_blank\" rel=\"noreferrer noopener\">FaceFusion Documentation<\/a>.\n\n\n\n<h3 class=\"wp-block-heading\">Related Tools and Technologies<\/h3>\n\n\n\n<p>FaceFusion is often compared with tools like DeepFaceLab, Reface AI, and Wav2Lip. Platforms like Vidnoz and Akool also provide similar AI face swap and deepfake functionalities. Python scripting, combined with libraries such as NumPy and the Open Neural Network Exchange (ONNX), forms the backbone of these applications. Using Google Colab can also help in leveraging powerful GPUs for free, making it easier to handle computationally intensive tasks like video face swap and stable diffusion modeling. FaceFusion with tools like Stable Diffusion can create innovative face swap and deepfake projects.\n\n\n\n<p>Embrace the future of AI-driven facial recognition and deepfake technology with FaceFusion and its comprehensive installation process on Ubuntu.\n","protected":false},"excerpt":{"rendered":"<p>FaceFusion is a powerful tool for facial recognition and analysis, often used for AI face swap applications, digital face replacement, and deepfake projects. Here\u2019s how [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":720,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[214],"tags":[193,46,18,66],"class_list":["post-636","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-installation","tag-deepfake","tag-faceswap","tag-ubuntu","tag-ubuntu-24-04"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/comments?post=636"}],"version-history":[{"count":7,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/636\/revisions"}],"predecessor-version":[{"id":1200,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/636\/revisions\/1200"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media\/720"}],"wp:attachment":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media?parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/categories?post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/tags?post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}