[Guide] macOS Install Guide: Installer Method

Installing and setting up FaceSwap


Forum rules

Read the FAQs and search the forum before posting a new topic.

Please mark any answers that fixed your problems so others can find the solutions.

User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

[Guide] macOS Install Guide: Installer Method

Post by torzdf »

Faceswap can be installed on macOS, both Intel and Apple Silicon.

Some notes if running a GPU on Intel:

  • Nvidia - you will likely run into problems. The last Nvidia drivers available on macOS are only on High Sierra. This means that, whilst the install option for Nvidia is there, Cuda will need to be installed, and Tensorflow 2.10 will need to be compiled to use the installed version of cuda (stock Tensorflow 2.10 will fail to install on High Sierra).
  • AMD - there is no direct support/testing. However, you should install the cpu version here. and see if your GPU is supported by macOS Metal. If so, you may have luck installing the tensorflow-metal plugin from apple.

Install Guide

  1. Open up Terminal and paste this command to download and launch the faceswap install script (do not execute this command as sudo or root):

    Code: Select all

    bash <(curl -s https://github.com/deepfakes/faceswap/releases/latest/download/faceswap_setup_macos.sh)

    On first run, the following error may display:

    00_a_fail_xcode.png
    00_a_fail_xcode.png (26.01 KiB) Viewed 62556 times

    If so, you need to follow these steps to install xcode:

    • A window should pop-up asking is you want to install xcode-select command line tools. You should select install
      01_a_install_xcode.png
      01_a_install_xcode.png (19.11 KiB) Viewed 62556 times
      • If the window did not pop-up for any reason, then you can manually launch the installer with:

        Code: Select all

        xcode-select install
    • Then accept the license terms
      01_b_xcode_toa.png
      01_b_xcode_toa.png (78.72 KiB) Viewed 62556 times
    • Then wait for it to finish installing.
      01_c_xcode_dl.png
      01_c_xcode_dl.png (12.98 KiB) Viewed 62556 times
    • Once the xcode-select installer has completed press Done
      01_d_xcode_installed.png
      01_d_xcode_installed.png (10.24 KiB) Viewed 62556 times
    • Re-run the faceswap install script:

      Code: Select all

      bash <(curl -s https://github.com/deepfakes/faceswap/releases/latest/download/faceswap_setup_macos.sh)
  2. The Faceswap Logo will display followed by some information. Make sure you read it thoroughly (specifically the part about user permissions on destination folders) then press Enter to continue.

    02_intro.png
    02_intro.png (47.6 KiB) Viewed 62554 times
  3. Apps - If any additional required apps are detected as missing, you are given the option to install them here.

    03_apps.png
    03_apps.png (15.2 KiB) Viewed 62554 times
    • XQuartz is required to display the GUI on macOS. You should select yes if this option is displayed.
  4. Conda - Faceswap uses Conda as it handles the installation of all prerequisites (git, Tensorflow etc) and contains them within their own environment, away from the rest of your system.

    • If an existing Conda install is found you will be asked if you want to use it. You should select Yes.
    • These next options will only be displayed if an existing Conda install was not found, or if you select No to using the existing Conda install.
      04_conda.png
      04_conda.png (45.36 KiB) Viewed 62554 times
      • Please specify a location for Conda: - The default install location for Conda will be fine in 99% of cases. If you do wish to install it elsewhere, then make sure that:
        1. Your user has permissions to write to the location you select.
        2. There are no spaces in the location that you provide (this is a Conda limitation and is outside of our control).
          If you are happy with the default location then just press Enter
      • Add Conda executable to path:. This is up to you, but it will make life easier if you say Yes. It basically means that you will have access to the conda command from the command line, and won't need to search for the executable inside the miniconda3 folder. Hit Enter to select the default value or press n if you don't want Conda added to your path.
      • Please specify a name for the Faceswap Conda Environment: Faceswap is run inside a "virtual environment". This is a Python environment that is kept separate from the rest of your system to avoid conflicts. The environment needs a name. The default should be fine, but if you have multiple installs then you will want to set a specific environment name here. NB: If an environment already exists with the name you select then it will be deleted (you will be notified if this will occur prior to commencing install). Press Enter to use the default faceswap or enter your preferred name here.
  5. Faceswap - Where you want Faceswap installed, and version selection

    05 faceswap.png
    05 faceswap.png (30.77 KiB) Viewed 62554 times
    • Please specify a location for Faceswap: The location that you want Faceswap installed to. The default will be fine in 99% of cases, but as with the Conda install, if you do select a different location, then make sure your user has permission to write to it. NB: If a folder pre-exists at the location given, then it will be deleted (you will be notified if this will occur prior to commencing install). Press Enter to use the default location or enter your preferred location here.
    • Faceswap version: For M1/M2 macs you must select 1 for Apple Silicon. For Intel, Faceswap can be run on Nvidia or AMD GPUs, but with caveats. See the notes at the beginning of this page. The software it installs varies depending on what you select here, so make sure you select the correct option for your system.
      Enter 1 for Apple Silicon, 2 for Nvidia, 3 for CPU
  6. Post Install Actions - A wrapper can be created to activate the environment and launch the GUI. This will be placed on the desktop, but can be moved anywhere more convenient. This makes opening Faceswap a lot easier, so unless you have a good reason not to, you should select Y here.

    06_launcher.png
    06_launcher.png (22.16 KiB) Viewed 62554 times
  7. Review - Finally you will be able to review your options. If you are happy press Y to proceed with the install, or press Enter to abort.

    07_review.png
    07_review.png (26.65 KiB) Viewed 62554 times
  8. Install - The installer will proceed to download the resources it needs from the internet and install as per your options.

    • If XQuartz was selected for installation, then it will be installed first and you will be prompted for the Adminstrator password:
      08_xquartz.png
      08_xquartz.png (17.95 KiB) Viewed 62551 times
    • The dependencies and Faceswap will then be installed. This may take some time.
      09_finish.png
      09_finish.png (19.63 KiB) Viewed 62551 times
    • Once complete, if selected, a launcher will be placed on the Desktop. You can place this launcher in applications/the dock or anywhere else that is convenient.
      10_launcher.png
      10_launcher.png (19.07 KiB) Viewed 62551 times
    • Note If XQuartz was installed you should log out and log in again for the GUI to work.
Last edited by torzdf on Fri Jul 14, 2023 1:02 pm, edited 5 times in total.

My word is final

User avatar
haoylee
Posts: 9
Joined: Thu Nov 18, 2021 3:16 pm
Has thanked: 1 time
Been thanked: 1 time

Re: [Guide] macOS Install Guide: Installer Method

Post by haoylee »

Great! Thanks a lot.

I wonder if the training efficiency could be fairly low than that running on PCs.

Also wondering if the unified memory on apple silicon devices play the VRAM role and thus improve the training performance.

User avatar
oscarspeed7
Posts: 1
Joined: Mon Jul 31, 2023 1:55 pm

Re: [Guide] macOS Install Guide: Installer Method

Post by oscarspeed7 »

Hey, thanks for the instructions, i am having a different problem and cant find any solution, please can i have some advice?

i have updated my M1 mac and xcode to latest versions but when i run it, it just looks like this:

Code: Select all

#!/bin/bash

TMP_DIR="/tmp/faceswap_install"

URL_CONDA="https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-"
DL_CONDA="${URL_CONDA}x86_64.sh"
DL_FACESWAP="https://github.com/deepfakes/faceswap.git"
DL_XQUARTZ="https://github.com/XQuartz/XQuartz/releases/latest/download/XQuartz-2.8.5.pkg"

CONDA_PATHS=("/opt" "$HOME")
CONDA_NAMES=("anaconda" "miniconda" "miniforge")
CONDA_VERSIONS=("3" "2")
CONDA_BINS=("/bin/conda" "/condabin/conda")
DIR_CONDA="$HOME/miniconda3"
CONDA_EXECUTABLE="${DIR_CONDA}/bin/conda"
CONDA_TO_PATH=false
ENV_NAME="faceswap"
PYENV_VERSION="3.10"

DIR_FACESWAP="$HOME/faceswap"
VERSION="nvidia"

DESKTOP=false
XQUARTZ=false

header() {
    # Format header text
    length=${#1}
    padding=$(( (72 - length) / 2))
    sep=$(printf '=%.0s' $(seq 1 $padding))
    echo ""
    echo $'\e[32m'$sep $1 $sep
}

info () {
    # output info message
    while read -r line ; do
        echo $'\e[32mINFO\e[39m    '$line
    done <<< "$(echo "$1" | fmt -s -w 70)"
}

warn () {
    # output warning message
    while read -r line ; do
        echo $'\e[33mWARNING\e[39m '$line
    done <<< "$(echo "$1" | fmt -s -w 70)"
}

error () {
    # output error message.
    while read -r line ; do
        echo $'\e[31mERROR\e[39m   '$line
    done <<< "$(echo "$1" | fmt -s -w 70)"
}

yellow () {
    # Change text color to yellow
    echo $'\e[33m'
}

check_file_exists () {
    # Check whether a file exists and return true or false
    test -f "$1"
}

check_folder_exists () {
    # Check whether a folder exists and return true or false
    test -d "$1"
}

download_file () {
    # Download a file to the temp folder
    fname=$(basename -- "$1")
    curl -L "$1" --output "$TMP_DIR/$fname" --progress-bar
}

check_for_sudo() {
    # Ensure user isn't running as sudo/root. We don't want to screw up any system install
    if [ "$EUID" == 0 ] ; then
        error "This install script should not be run with root privileges. Please run as a normal user."
        exit 1
    fi
}

check_for_curl() {
    # Ensure that curl is available on the system
    if ! command -V curl &> /dev/null ; then
        error "'curl' is required for running the Faceswap installer, but could not be found. \
        Please install 'curl' before proceeding."
        exit 1
    fi
}

check_for_xcode() {
    # Ensure that xcode command line tools are available on the system
    if xcode-select -p 2>&1 | grep -q "xcode-select: error" ; then
        error "Xcode is required to install faceswap. Please install Xcode Command Line Tools \
        before proceeding. If the Xcode installer does not automatically open, then \
        you can run the command:"
        error "xcode-select --install"
        echo ""
        xcode-select --install
        exit 1
    fi
}

create_tmp_dir() {
    TMP_DIR="$(mktemp -d)"
    if [ -z "$TMP_DIR" -o ! -d "$TMP_DIR" ]; then
        # This shouldn't happen, but just in case to prevent the tmp cleanup function to mess things up.
        error "Failed creating the temporary install directory."
        exit 2
    fi
    trap cleanup_tmp_dir EXIT
}

cleanup_tmp_dir() {
  rm -rf "$TMP_DIR"
}

ask () {
    # Ask for input. First parameter: Display text, 2nd parameter variable name
    default="${!2}"
    read -rp $'\e[35m'"$1 [default: '$default']: "$'\e[39m' inp
    inp="${inp:-${default}}"
    if [ "$inp" == "\n" ] ; then inp=${!2} ; fi
    printf -v $2 "$inp"
}

ask_yesno () {
    # Ask yes or no. First Param: Question, 2nd param: Default
    # Returns True for yes, False for No
    case $2 in
        [Yy]* ) opts="[YES/no]" ;;
        [Nn]* ) opts="[yes/NO]" ;;
    esac
    while true; do
        read -rp $'\e[35m'"$1 $opts: "$'\e[39m' yn
        yn="${yn:-${2}}"
        case $yn in
            [Yy]* ) retval=true ; break ;;
            [Nn]* ) retval=false ; break ;;
            * ) echo "Please answer yes or no." ;;
        esac
    done
    $retval
}


ask_version() {
    # Ask which version of faceswap to install
    while true; do
        default=1
        read -rp $'\e[35mSelect:\t1: Apple Silicon\n\t2: NVIDIA\n\t3: CPU\n'"[default: $default]: "$'\e[39m' vers
        vers="${vers:-${default}}"
        case $vers in
            1) VERSION="apple_silicon" ; break ;;
            2) VERSION="nvidia" ; break ;;
            3) VERSION="cpu" ; break ;;
            * ) echo "Invalid selection." ;;
        esac
    done
}

banner () {
    echo $'      \e[32m                   001'
    echo $'      \e[32m                  11 10  010'
    echo $'      \e[39m         @@@@\e[32m      10'
    echo $'      \e[39m      @@@@@@@@\e[32m         00     1'
    echo $'      \e[39m    @@@@@@@@@@\e[32m  1  1            0'
    echo $'      \e[39m  @@@@@@@@\e[32m    0000 01111'
    echo $'      \e[39m @@@@@@@@@@\e[32m    01  110 01  1'
    echo $'      \e[39m@@@@@@@@@@@@\e[32m 111    010    0'
    echo $'      \e[39m@@@@@@@@@@@@@@@@\e[32m  10    0'
    echo $'      \e[39m@@@@@@@@@@@@@\e[32m   0010   1'
    echo $'      \e[39m@@@@@@@@@  @@@\e[32m   100         1'
    echo $'      \e[39m@@@@@@@ .@@@@\e[32m  10       1'
    echo $'      \e[39m #@@@@@@@@@@@\e[32m  001       0'
    echo $'      \e[39m   @@@@@@@@@@@  ,'
    echo '         @@@@@@@@  @@@@@'
    echo '        @@@@@@@@ @@@@@@@@    _'
    echo '       @@@@@@@@@,@@@@@@@@  / _|'
    echo '       %@@@@@@@@@@@@@@@@@ | |_  ___ '
    echo '           @@@@@@@@@@@@@@ |  _|/ __|'
    echo '            @@@@@@@@@@@@  | |  \__ \'
    echo '             @@@@@@@@@@(  |_|  |___/'
    echo '                @@@@@@'
    echo '                 @@@@'
    sleep 2
}

find_conda_install() {
    if check_conda_path;
        then true
        elif check_conda_locations ; then true
        else false
    fi
}

set_conda_dir_from_bin() {
    # Set the DIR_CONDA variable from the bin file
    pth="$(dirname "$1")/.."
    DIR_CONDA=$(python -c "import os, sys; print(os.path.realpath('$pth'))")
    info "Found existing conda install at: $DIR_CONDA"
}

check_conda_path()  {
    # Check if conda is in PATH
    conda_bin="$(which conda 2>/dev/null)"
    if [[ "$?" == "0" ]]; then
        set_conda_dir_from_bin "$conda_bin"
        CONDA_EXECUTABLE="$conda_bin"
        true
    else
        false
    fi
}

check_conda_locations() {
    # Check common conda install locations
    retval=false
    for path in "${CONDA_PATHS[@]}"; do
        for name in "${CONDA_NAMES[@]}" ; do
            foldername="$path/$name"
            for vers in "${CONDA_VERSIONS[@]}" ; do
                for bin in "${CONDA_BINS[@]}" ; do
                    condabin="$foldername$vers$bin"
                    if check_file_exists "$condabin" ; then
                        set_conda_dir_from_bin "$condabin"
                        CONDA_EXECUTABLE="$condabin";
                        retval=true
                        break 4
                    fi
                done
            done
        done
    done
    $retval
}

user_input() {
    # Get user options for install
    header "Welcome to the macOS Faceswap Installer"
    info "To get setup we need to gather some information about where you would like Faceswap\
    and Conda to be installed."
    info "To accept the default values just hit the 'ENTER' key for each option. You will have\
    an opportunity to review your responses prior to commencing the install."
    echo ""
    info "IMPORTANT: Make sure that the user '$USER' has full permissions for all of the\
    destinations that you select."
    read -rp $'\e[35m'"Press 'ENTER' to continue with the setup..."$'\e[39m'
    apps_opts
    conda_opts
    faceswap_opts
    post_install_opts
}

apps_opts () {
    # Options pertaining to additional apps that are required
    if ! command -V xquartz &> /dev/null ; then
        header "APPS"
        info "XQuartz is required to use the Faceswap GUI but was not detected. "
        if ask_yesno "Install XQuartz for GUI support?" "Yes" ; then
            XQUARTZ=true
        fi
    fi
}

conda_opts () {
    # Options pertaining to the installation of conda
    header "CONDA"
    info "Faceswap uses Conda as it handles the installation of all prerequisites."
    if find_conda_install && ask_yesno "Use the pre installed conda?" "Yes"; then
        info "Using Conda install at $DIR_CONDA"
    else
        echo ""
        info "If you have an existing Conda install then enter the location here,\
        otherwise Miniconda3 will be installed in the given location."
        err_msg="The location for Conda must not contain spaces (this is a specific\
        limitation of Conda)."
        tmp_dir_conda="$DIR_CONDA"
        while true ; do
            ask "Please specify a location for Conda." "DIR_CONDA"
            case ${DIR_CONDA} in
                *\ * ) error "$err_msg" ; DIR_CONDA=$tmp_dir_conda ;;
                * ) break ;;
            esac
        CONDA_EXECUTABLE="${DIR_CONDA}/bin/conda"
        done
    fi
    if ! check_file_exists "$CONDA_EXECUTABLE" ; then
        echo ""
        info "The Conda executable can be added to your PATH. This makes it easier to run Conda\
        commands directly. If you already have a pre-existing Conda install then you should\
        probably not enable this, otherwise this should be fine."
        if ask_yesno "Add Conda executable to path?" "Yes" ; then CONDA_TO_PATH=true ; fi
    fi
    echo ""
    info "Faceswap will be installed inside a Conda Environment. If an environment already\
    exists with the name specified then it will be deleted."
    ask "Please specify a name for the Faceswap Conda Environmnet" "ENV_NAME"
}

faceswap_opts () {
    # Options pertaining to the installation of faceswap
    header "FACESWAP"
    info "Faceswap will be installed in the given location. If a folder exists at the\
    location you specify, then it will be deleted."
    ask "Please specify a location for Faceswap" "DIR_FACESWAP"
    echo ""
    info "Faceswap can be run on Apple Silicon (M1, M2 etc.), compatible NVIDIA gpus, or on CPU. You should make sure that any \
    drivers are up to date. Please select the version of Faceswap you wish to install."
    ask_version
    if [ $VERSION == "apple_silicon" ] ; then
        DL_CONDA="${URL_CONDA}arm64.sh"
    fi
}

post_install_opts() {
    # Post installation options
    header "POST INSTALLATION ACTIONS"
    info "Launching Faceswap requires activating your Conda Environment and then running\
    Faceswap. The installer can simplify this by creating an Application Launcher file and placing it \
    on your desktop to launch straight into the Faceswap GUI"
    if ask_yesno "Create FaceswapGUI Launcher?" "Yes" ; then
        DESKTOP=true
    fi
}

review() {
    # Review user options and ask continue
    header "Review install options"
    info "Please review the selected installation options before proceeding:"
    echo ""
    if $XQUARTZ ; then echo "        - The XQuartz installer will be downloaded and launched" ; fi
    if ! check_folder_exists "$DIR_CONDA"
        then
            echo "        - MiniConda3 will be installed in '$DIR_CONDA'"
        else
            echo "        - Existing Conda install at '$DIR_CONDA' will be used"
    fi
    if $CONDA_TO_PATH ; then echo "        - MiniConda3 will be added to your PATH" ; fi
    if check_env_exists ; then
        echo $'        \e[33m- Existing Conda Environment '$ENV_NAME $' will be removed\e[39m'
    fi
    echo "        - Conda Environment '$ENV_NAME' will be created."
    if check_folder_exists "$DIR_FACESWAP" ; then
        echo $'        \e[33m- Existing Faceswap folder '$DIR_FACESWAP $' will be removed\e[39m'
    fi
    echo "        - Faceswap will be installed in '$DIR_FACESWAP'"
    echo "        - Installing for '$VERSION'"
    if [ $VERSION == "nvidia" ] ; then
        echo $'          \e[33m- Note: Please ensure that Nvidia drivers are installed prior to proceeding\e[39m'
    fi
    if $DESKTOP ; then echo "        - An Application Launcher will be created" ; fi
    if ! ask_yesno "Do you wish to continue?" "No" ;  then exit ; fi
}

xquartz_install() {
    # Download and install XQuartz
    if $XQUARTZ ; then
        info "Downloading XQuartz..."
        yellow ; download_file $DL_XQUARTZ
        echo ""

        info "Installing XQuartz..."
        info "Admin password required to install XQuartz:"
        fname="$(basename -- $DL_XQUARTZ)"
        yellow ; sudo installer -pkg "$TMP_DIR/$fname" -target /
        echo ""
    fi
}

conda_install() {
    # Download and install Mini Conda3
    if ! check_folder_exists "$DIR_CONDA" ; then
        info "Downloading Miniconda3..."
        yellow ; download_file $DL_CONDA
        info "Installing Miniconda3..."
        yellow ; fname="$(basename -- $DL_CONDA)"
        bash "$TMP_DIR/$fname" -b -p "$DIR_CONDA"
        if $CONDA_TO_PATH ; then
            info "Adding Miniconda3 to PATH..."
            yellow ; "$CONDA_EXECUTABLE" init zsh bash
            "$CONDA_EXECUTABLE" config --set auto_activate_base false
        fi
    fi
}

check_env_exists() {
    # Check if an environment with the given name exists
    if check_file_exists "$CONDA_EXECUTABLE" ; then
        "$CONDA_EXECUTABLE" env list | grep -qE "^${ENV_NAME}\W"
    else false
    fi
}

delete_env() {
    # Delete the env if it previously exists
    if check_env_exists ; then
        info "Removing pre-existing Virtual Environment"
        yellow ; "$CONDA_EXECUTABLE" env remove -n "$ENV_NAME"
    fi
}

create_env() {
    # Create Python 3.10 env for faceswap
    delete_env
    info "Creating Conda Virtual Environment..."
    yellow ; "$CONDA_EXECUTABLE" create -n "$ENV_NAME" -q python="$PYENV_VERSION" -y
}


activate_env() {
    # Activate the conda environment
    # shellcheck source=/dev/null
    source "$DIR_CONDA/etc/profile.d/conda.sh" activate
    conda activate "$ENV_NAME"
}

delete_faceswap() {
    # Delete existing faceswap folder
    if check_folder_exists "$DIR_FACESWAP" ; then
        info "Removing Faceswap folder: '$DIR_FACESWAP'"
        rm -rf "$DIR_FACESWAP"
    fi
}

clone_faceswap() {
    # Clone the faceswap repo
    delete_faceswap
    info "Downloading Faceswap..."
    yellow ; git clone --depth 1 --no-single-branch "$DL_FACESWAP" "$DIR_FACESWAP"
}

setup_faceswap() {
    # Run faceswap setup script
    info "Setting up Faceswap..."
    python -u "$DIR_FACESWAP/setup.py" --installer --$VERSION
}

create_gui_launcher () {
    # Create a shortcut to launch into the GUI
    launcher="$DIR_FACESWAP/faceswap_gui_launcher.command"
    launch_script="#!/bin/bash\n"
    launch_script+="source \"$DIR_CONDA/etc/profile.d/conda.sh\" activate && \n"
    launch_script+="conda activate '$ENV_NAME' && \n"
    launch_script+="python \"$DIR_FACESWAP/faceswap.py\" gui"
    printf "$launch_script" > "$launcher"
    chmod +x "$launcher"
}

create_app_on_desktop () {
    # Create a simple .app wrapper to launch GUI
    if $DESKTOP ; then
        app_name="FaceswapGUI"
        app_dir="$TMP_DIR/$app_name.app"

        unzip -qq "$DIR_FACESWAP/.install/macos/app.zip" -d "$TMP_DIR"

        script="#!/bin/bash\n"
        script+="bash \"$DIR_FACESWAP/faceswap_gui_launcher.command\""
        printf "$script" > "$app_dir/Contents/Resources/script"
        chmod +x "$app_dir/Contents/Resources/script"

        rm -rf "$HOME/Desktop/$app_name.app"
        mv "$app_dir" "$HOME/Desktop"
    fi ;
}

check_for_sudo
check_for_curl
check_for_xcode
banner
user_input
review
create_tmp_dir
xquartz_install
conda_install
create_env
activate_env
clone_faceswap
setup_faceswap
create_gui_launcher
create_app_on_desktop
info "Faceswap installation is complete!"
if $CONDA_TO_PATH ; then
    info "You should close the terminal before proceeding" ; fi
if $DESKTOP ; then info "You can launch Faceswap from the icon on your desktop" ; fi
if $XQUARTZ ; then
    warn "XQuartz has been installed. You must log out and log in again to be able to use the GUI" ; fi
xcode-select install
Last edited by torzdf on Tue Aug 01, 2023 9:59 am, edited 1 time in total.
User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

That's just displaying the contents of the install script. Make sure that you are executing the script rather than opening it for editing.

This command should just download and execute it for you:

Code: Select all

bash <(curl -s https://github.com/deepfakes/faceswap/releases/latest/download/faceswap_setup_macos.sh)

Otherwise, if you download the file, you can open a terminal in the download location and enter

Code: Select all

bash ./faceswap_setup_macos.sh
Last edited by torzdf on Thu Aug 03, 2023 10:30 am, edited 2 times in total.

My word is final

User avatar
Wadi
Posts: 1
Joined: Thu Aug 03, 2023 9:52 am

Re: [Guide] macOS Install Guide: Installer Method

Post by Wadi »

Hello,
I am MacOS user (High Sierra 10.13.6 with intel )
Installation was completed but when I click the FaceswapGUI nothing show up in the screen.
I am wondering if I was missing something during installation. During installation I notice : cudatoolkit, opencv-python, and tensorlfow could not install and must install manually. Could this be the reason or I missed something prior to installation? Thank you.

Last edited by Wadi on Thu Aug 03, 2023 10:53 am, edited 1 time in total.
User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

Unfortunately I am not a macOS expert. All I can say is that I have tested that the install script downloads and works on macOS.

You can also download the install script directly from:
https://github.com/deepfakes/faceswap/r ... p_macos.sh

Open up terminal and navigate to the Downloads folder, then execute

Code: Select all

bash ./faceswap_setup_macos.sh

My word is final

User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

Wadi wrote: Thu Aug 03, 2023 9:59 am

Hello,
I am MacOS user (High Sierra 10.13.6 with intel )
Installation was completed but when I click the FaceswapGUI nothing show up in the screen.
I am wondering if I was missing something during installation. During installation I notice : cudatoolkit, opencv-python, and tensorlfow could not install and must install manually. Could this be the reason or I missed something prior to installation? Thank you.

What GPU do you have?

Either way, unfortunately installing on Intel Mac with Nvidia GPU is non-trivial and can't be entirely handled by the install script. This is because Apple dropped Nvidia support a long time ago, so applications that are required by Faceswap cannot be installed through our standard install system.

Unfortunately, whilst I have a macOS High Sierra machine to test the install script on, it does not have an Nvidia GPU attached, so I cannot fully test the process,

See these notes in the original post:

Nvidia - you will likely run into problems. The last Nvidia drivers available on macOS are only on High Sierra. This means that, whilst the install option for Nvidia is there, Cuda will need to be installed, and Tensorflow 2.10 will need to be compiled to use the installed version of cuda (stock Tensorflow 2.10 will fail to install on High Sierra).

My word is final

User avatar
lloyd72
Posts: 1
Joined: Mon Aug 14, 2023 11:05 am

Re: [Guide] macOS Install Guide: Installer Method

Post by lloyd72 »

why is it not opening after installing and showing on my desktop screen

User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

You'll need to provide a bit more information than that.

What I suggest you do is manually launch Faceswap and see what (if any) error message is generated.

If open up Terminal and navigate to the faceswap folder (usually /users/<username>/faceswap) then execute the launcher script:

Code: Select all

faceswap_gui_launcher.command

You should find out what may be going wrong.

My word is final

User avatar
hullo
Posts: 16
Joined: Wed Aug 23, 2023 8:30 am
Been thanked: 1 time

Re: [Guide] macOS Install Guide: Installer Method

Post by hullo »

Hi, I'm having trouble launching the app after installation. The launcher flashes an empty window for a split second and that's it. I tried the command line launcher and got this:

Code: Select all

Last login: Wed Aug 23 20:01:28 on ttys000
/Users/joshua/faceswap/faceswap_gui_launcher.command ; exit;
joshua@Joshuas-Mac-Studio ~ % /Users/joshua/faceswap/faceswap_gui_launcher.command ; exit;
/Users/joshua/faceswap/faceswap_gui_launcher.command: line 2: /Users/joshua/etc/profile.d/conda.sh: No such file or directory

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

So I made a copy of the command line launcher and changed the directory to exactly where that "conda.sh" file is (/Users/joshua/miniconda3/etc/profile.d/conda.sh) and got this instead, and still no app lauch:

Code: Select all

Last login: Wed Aug 23 20:01:58 on ttys000
/Users/joshua/faceswap_gui_launcher_edit.command ; exit;
joshua@Joshuas-Mac-Studio ~ % /Users/joshua/faceswap_gui_launcher_edit.command ; exit;
Traceback (most recent call last):
  File "/Users/joshua/faceswap/faceswap.py", line 12, in <module>
    from lib.cli import args as cli_args  # pylint:disable=wrong-import-position
  File "/Users/joshua/faceswap/lib/cli/args.py", line 13, in <module>
    from lib.utils import get_backend
  File "/Users/joshua/faceswap/lib/utils.py", line 20, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

Any ideas? Fwiw I installed Xcode and XQuartz. Mac Studio, Ventura 13.5

Last edited by torzdf on Thu Aug 24, 2023 9:12 am, edited 1 time in total.
User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

Hmmm, it's not launching correctly (or not finding Conda correctly, for some reason).

Please try the following:

Code: Select all

conda activate faceswap
cd faceswap
python faceswap.py gui

This is effectively what the launcher does, but will help us nail down the issue.

My word is final

User avatar
hullo
Posts: 16
Joined: Wed Aug 23, 2023 8:30 am
Been thanked: 1 time

Re: [Guide] macOS Install Guide: Installer Method

Post by hullo »

torzdf wrote: Thu Aug 24, 2023 9:14 am

Hmmm, it's not launching correctly (or not finding Conda correctly, for some reason).

Please try the following:

Code: Select all

conda activate faceswap
cd faceswap
python faceswap.py gui

This is effectively what the launcher does, but will help us nail down the issue.

Thanks. I get the same error as last time with the addition of:

ModuleNotFoundError: No module named 'numpy'

User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

Ok. for some reason your environment hasn't installed correctly. Could you provide the file faceswap_setup.log from the faceswap folder please.

My word is final

User avatar
hullo
Posts: 16
Joined: Wed Aug 23, 2023 8:30 am
Been thanked: 1 time

Re: [Guide] macOS Install Guide: Installer Method

Post by hullo »

UPDATE: I tried reinstalling, and attached a text file from Terminal. I no longer see the errors pasted below from the first installation process, but I still get the same error when trying to launch.

torzdf wrote: Sat Aug 26, 2023 10:10 am

Ok. for some reason your environment hasn't installed correctly. Could you provide the file faceswap_setup.log from the faceswap folder please.

Yikes. No such file. But I did save the install process to a pdf. It's not letting me attach it, but here's the part that looks problematic, near the end (and I did log out/log in):

Code: Select all

INFO Installing ffmpy>=0.3.0
INFO "ffmpy>=0.3.0" not available in Conda. Installing with pip
INFO Installing ffmpy>=0.3.0
WARNING Couldn't install ffmpy>=0.3.0 with pip. Please install this package manually

INFO Installing tensorflow-macos<2.11.0,>=2.10.0
INFO "tensorflow-macos<2.11.0,>=2.10.0" not available in Conda. Installing with pip
INFO Installing tensorflow-macos<2.11.0,>=2.10.0
WARNING Couldn't install tensorflow-macos<2.11.0,>=2.10.0 with pip. Please install this package manually INFO Installing tensorflow-deps<2.11.0,>=2.10.0

INFO "tensorflow-deps<2.11.0,>=2.10.0" not available in Conda. Installing with pip
INFO Installing tensorflow-deps<2.11.0,>=2.10.0
WARNING Couldn't install tensorflow-deps<2.11.0,>=2.10.0 with pip. Please install this package manually INFO Installing tensorflow-metal>=0.6.0,<0.7.0

INFO "tensorflow-metal>=0.6.0,<0.7.0" not available in Conda. Installing with pip
INFO Installing tensorflow-metal>=0.6.0,<0.7.0
WARNING Couldn't install tensorflow-metal>=0.6.0,<0.7.0 with pip. Please install this package manually INFO Installing decorator

INFO decorator not available in Conda. Installing with pip
INFO Installing decorator
WARNING Couldn't install decorator with pip. Please install this package manually

INFO Installing cloudpickle
INFO cloudpickle not available in Conda. Installing with pip
INFO Installing cloudpickle
WARNING Couldn't install cloudpickle with pip. Please install this package manually

ERROR Some packages failed to install. This may be a temporary error which might be fixed by re-running th is script. Otherwise please install these packages manually.
INFO Faceswap installation is complete!
INFO You should close the terminal before proceeding
INFO You can launch Faceswap from the icon on your desktop
WARNING XQuartz has been installed. You must log out and log in again to be
WARNING able to use the GUI
Attachments
Terminal Saved Output.txt
(6.97 KiB) Downloaded 1480 times
Last edited by torzdf on Sun Aug 27, 2023 1:05 pm, edited 2 times in total.
User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

Ok, this is all a bit mystifying, other macOS users have not reported this issue.

If it is not generating the log file, then there are definitely issues!

From the attached output, it appears to not find a location for where miniconda is installed, it then also fails to run some command.

Most likely you have some kind of issues/conflicts on your system. In the first instance you could try following the macOS equivalent of this:
app.php/faqpage#f1r1

Otherwise, the best I can offer, at this stage, is to follow the manual install steps:
https://github.com/deepfakes/faceswap/b ... tall-guide

My word is final

User avatar
lev12354
Posts: 7
Joined: Thu Aug 31, 2023 1:16 pm
Has thanked: 3 times
Been thanked: 1 time

Re: [Guide] macOS Install Guide: Installer Method

Post by lev12354 »

Good afternoon, I have a mac with intel processor and amd rx 590 ( metal 2.0). The question is about the performance of the GPU. Ventura 5.1 system

As I understood from the instructions, first I need to install faceswap with CPU configuration via github script for macos, and only then tenserflow-metal and tenserflow-macos dependency for GPU. But the question is, how can I make it so that the GPU is also detected at startup? Because in the end I see only CPU in faceswap, and no hint about GPU.

User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

Unfortunately I do not own a Mac with an Intel card to be able to tell you this. The original instructions are based on what should work based on the research I did.

I'm not sure how many Faceswap users have Intel Macs with AMD cards, so you may be better off asking in a more general purpose Tensorflow forum

lev12354 wrote: Thu Aug 31, 2023 1:22 pm

how can I make it so that the GPU is also detected at startup? Because in the end I see only CPU in faceswap, and no hint about GPU.

Tensorflow metal should automatically pick up your GPU, but without an Intel Mac with AMD GPU to test on, I can't confirm this

Last edited by torzdf on Thu Aug 31, 2023 9:44 pm, edited 1 time in total.

My word is final

User avatar
lev12354
Posts: 7
Joined: Thu Aug 31, 2023 1:16 pm
Has thanked: 3 times
Been thanked: 1 time

Re: [Guide] macOS Install Guide: Installer Method

Post by lev12354 »

torzdf wrote: Thu Aug 31, 2023 9:43 pm

Unfortunately I do not own a Mac with an Intel card to be able to tell you this. The original instructions are based on what should work based on the research I did.

I'm not sure how many Faceswap users have Intel Macs with AMD cards, so you may be better off asking in a more general purpose Tensorflow forum

lev12354 wrote: Thu Aug 31, 2023 1:22 pm

how can I make it so that the GPU is also detected at startup? Because in the end I see only CPU in faceswap, and no hint about GPU.

Tensorflow metal should automatically pick up your GPU, but without an Intel Mac with AMD GPU to test on, I can't confirm this

Do I understand correctly that in the program itself will be displayed only CPU, but as soon as I run for example training, then in fact will work both CPU and GPU?

User avatar
torzdf
Posts: 2667
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 131 times
Been thanked: 625 times

Re: [Guide] macOS Install Guide: Installer Method

Post by torzdf »

GPU is used for training/extract/convert etc.

If you run with loglevel VERBOSE then you should get an output from Tensorflow saying which device it is using

My word is final

User avatar
hullo
Posts: 16
Joined: Wed Aug 23, 2023 8:30 am
Been thanked: 1 time

Re: [Guide] macOS Install Guide: Installer Method

Post by hullo »

torzdf wrote: Sun Aug 27, 2023 1:09 pm

Ok, this is all a bit mystifying, other macOS users have not reported this issue.

If it is not generating the log file, then there are definitely issues!

From the attached output, it appears to not find a location for where miniconda is installed, it then also fails to run some command.

Most likely you have some kind of issues/conflicts on your system. In the first instance you could try following the macOS equivalent of this:
https://forum.faceswap.dev/app.php/faqpage#f1r1

Otherwise, the best I can offer, at this stage, is to follow the manual install steps:
https://github.com/deepfakes/faceswap/b ... tall-guide

Success! Thanks for your patience and guidance.

And now the hard part. Tiny black font against dark gray background. :shock:

Post Reply