-
-
Save xenogenesi/e62d3d13dadbc164124c830e9c453668 to your computer and use it in GitHub Desktop.
# Ignore everything | |
** | |
# Allow files and directories | |
!/audio.py | |
!/Dockerfile | |
!/hparams.py | |
!/preprocess.py | |
!/checkpoints/ | |
!/evaluation/ | |
!/hq_wav2lip_train.py | |
!/README.md | |
!/temp/ | |
!/color_syncnet_train.py | |
!/face_detection/ | |
!/inference.py | |
!/requirements.txt | |
!/filelists/ | |
!/models/ | |
!/results/ | |
!/wav2lip_train.py | |
# Ignore unnecessary files inside allowed directories | |
# This should go after the allowed directories | |
**/*~ | |
**/*.log | |
**/.DS_Store | |
**/Thumbs.db |
# 1. install a version of docker with gpu support (docker-ce >= 19.03) | |
# 2. enter the project directory and build the wav2lip image: | |
# docker build -t wav2lip . | |
# 3. allow root user to connect to the display | |
# xhost +local:root | |
# 4. instantiate the container | |
# docker run --rm --gpus all -v /tmp/.X11-unix:/tmp/.X11-unix -v $PWD:/workspace/src -e DISPLAY=$DISPLAY --device /dev/dri -ti wav2lip bash | |
# NOTES: | |
# export CUDA_VISIBLE_DEVICES="" ## force cpu only | |
# Based on https://github.com/1adrianb/face-alignment/blob/master/Dockerfile | |
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 | |
RUN export DEBIAN_FRONTEND=noninteractive RUNLEVEL=1 ; \ | |
apt-get update && apt-get install -y --no-install-recommends \ | |
build-essential cmake git curl ca-certificates \ | |
vim \ | |
python3-pip python3-dev python3-wheel \ | |
libglib2.0-0 libxrender1 python3-soundfile \ | |
ffmpeg && \ | |
rm -rf /var/lib/apt/lists/* && \ | |
pip3 install --upgrade setuptools | |
# RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ | |
# chmod +x ~/miniconda.sh && \ | |
# ~/miniconda.sh -b -p /opt/conda && \ | |
# rm ~/miniconda.sh | |
# ENV PATH /opt/conda/bin:$PATH | |
# RUN conda config --set always_yes yes --set changeps1 no && conda update -q conda | |
# RUN conda install pytorch torchvision cudatoolkit=10.1 -c pytorch | |
# # Install Wav2Lip package | |
# # NOTE we use the git clone to install the requirements only once | |
# # (if we use COPY it will invalidate the cache and reinstall the dependencies for every change in the sources) | |
WORKDIR /workspace | |
RUN chmod -R a+w /workspace | |
RUN git clone https://github.com/Rudrabha/Wav2Lip | |
WORKDIR /workspace/Wav2Lip | |
RUN pip3 install -r requirements.txt | |
RUN mkdir -p /root/.cache/torch/checkpoints && \ | |
curl -SL -o /root/.cache/torch/checkpoints/s3fd-619a316812.pth "https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth" | |
# !!! NOTE !!! nvidia-driver version must match the version installed on the host(/docker server) | |
RUN export DEBIAN_FRONTEND=noninteractive RUNLEVEL=1 ; \ | |
apt-get update && apt-get install -y --no-install-recommends \ | |
nvidia-driver-450 mesa-utils && \ | |
rm -rf /var/lib/apt/lists/* | |
# create the working directory, to be mounted with the bind option | |
RUN mkdir /workspace/src | |
WORKDIR /workspace/src |
- Do you have working Wav2Lip ?
- chatgpt says opencv-python==4.1.0.25 does not support Python 3.6
This version was built for Python 3.7+.
Edit: But you had it working with Python 3.6, right ?
That's funny 'cause chatgpt told me python 3.6, 3.7 and 3.8 all support opencv-python==4.1.0.25
No, I haven't used it for years. From the issue you linked, I'd say back then I used Python 3.6. Today, if I had to reinstall it, I would avoid using the docker-nvidia image; I would use conda (not miniconda) directly with a Python 3.6 venv (now out of curiosity I'll try).
@vido89 so, I tried it with conda, without docker-nvidia
I gave up with py36 because the build of opencv-contrib-python was extremely slow (some bug in the wheel I guess)
py37 got it working, generated an mp4 from a wav and an mp4 using gpu
# install conda
conda create -n py37wav2lip python=3.7
conda activate py37wav2lip
# double upgrade might be unnecessary, just in case (for problem with py36 opencv-contrib-python wheel)
pip install --upgrade pip setuptools wheel
pip install --upgrade pip
sudo apt install ffmpeg
git clone https://github.com/Rudrabha/Wav2Lip.git
cd Wav2Lip
# conflict between opencv-python version and opencv-contrib-python version
# but apparently opencv-contrib-python isn't even used, try remove it from requirements.txt and skip next step
pip install -r requirements.txt
# found in some (opencv / opencv headless issue)
pip uninstall opencv-python-headless ; pip uninstall opencv-contrib-python ; pip uninstall opencv-python
pip install opencv-python==4.1.0.25
# for cuda support (found in some gpu not working issue)
pip install torch==1.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
pip install torchvision==0.11.3+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
# download checkpoints .pth from github Wav2Lip page into checkpoints/ directory
# don't know if this is needed
mkdir -p ~/.cache/torch/checkpoints
curl -SL -o ~/.cache/torch/checkpoints/s3fd-619a316812.pth "https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth"
# run inference
python inference.py --checkpoint_path checkpoints/wav2lip.pth --face /tmp/input.mp4 --audio /tmp/sample_10.wav
@xenogenesi Awesome can you help me to write Dockerfile
ERROR: failed to solve: dockerfile parse error on line 2: unknown instruction: conda
@vido89 is there any reason you absolutely need it to work with docker?
Just install conda on your system, and run the commands shown, so much easier
@xenogenesi Aha OK, so I need to install Anaconda3-2024.10-1-Linux-x86_64.sh
right ?
@xenogenesi Aha OK, so I need to install
Anaconda3-2024.10-1-Linux-x86_64.sh
right ?
Yes it seems to me the right one, follow their instructions, it is easy, you can find many tutorials online on how to install and use conda
@xenogenesi Aha OK
# but apparently opencv-contrib-python isn't even used, try remove it from requirements.txt and skip next step
So should I run pip install -r requirements.txt
?
# but apparently opencv-contrib-python isn't even used, try remove it from requirements.txt and skip next step
So should I run
pip install -r requirements.txt
?
I would make a try, edit requirements.txt
and remove opencv-contrib-python
and then run pip install -r requirements.txt
, then skip my step that remove all opencv stuff and reinstall only the one package. But if that doesn't work keep the requirements as it were and follow all the steps.
Note: I just encoded one video and I had no problems, but I don't know if using different models or training Wav2Lip are gonna break because opencv-contrib-python is missing.
edit: I removed opencv-contrib-python because there was some version conflict with the opencv package, if you can pip install the requirements without errors.. even better.
@xenogenesi I installed cuda but I got this error
RuntimeError: Image too big to run face detection on GPU
how do I force it to run on CPU ?
@xenogenesi I installed cuda but I got this error
RuntimeError: Image too big to run face detection on GPU
how do I force it to run on CPU ?
Don't know, look in the Wav2Lip repository (the closed issues also), perhaps some env variable. I guess using the cpu will be very slow, and I think I saw somewhere on Wav2Lip repo that it is trained on small sizes.
It works, I cant believe this ! You are the men! Thank you @xenogenesi
Edit: is it due to ffmpeg to getting "pixelated" video ?
@vido89 Cool, I'm glad you made it work, sorry but I can't tell you why it's pixelated, I've only used it briefly
@xenogenesi OK Thank you once again !
great, that's the same error as before, installing libssl1.1 solved nothing, the Dockerfile looks fine
update
You know, the symbol still exists on openssl 3 I wonder if isn't just some openssl package that need to be installed as a required dependency before conda/python3.6