-
Notifications
You must be signed in to change notification settings - Fork 216
Initiate "animation" component #775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 28 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
f0c7a02
updates needed for demo
ctao456 81a5943
Merge branch 'ctao/demo' of https://github.com/ctao456/GenAIComps int…
ctao456 dbf8ad3
original pr content
ctao456 98cbb1c
Merge branch 'opea-project:main' into ctao/opea
ctao456 d85f33a
Revert "updates needed for demo"
ctao456 a8363b7
remove improper images
ctao456 4c22b40
Addressed some comments on previous pr
ctao456 dc59a77
Add Dockerfile for cpu support
ctao456 bf38204
CODEOWNER: Update comp CODEOWNER (#757)
hteeyeoh b932b94
Add stable diffusion microservice (#729)
XinyuYe-Intel 7fb8c6b
Compatible with different platforms. (#766)
ZePan110 817c0f1
Optimize path and link validity check. (#745)
ZePan110 a14c76f
Add timeout for ut test (#773)
chensuyue 8fae482
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b9420c7
Merge branch 'opea-project:main' into ctao/opea
ctao456 1879a1d
test hyperlink
ctao456 cc938fb
test hyperlink
ctao456 697fdbd
test hyperlink issue
ctao456 120edae
test hyperlink issue
ctao456 4bfd1f3
put back hyperlinks in readme
ctao456 10b3b34
remove possible error hyperlink
ctao456 09ab934
put hyperlink back
ctao456 901adcc
Merge branch 'opea-project:main' into ctao/opea
ctao456 303eb1f
major update to use FastAPI for wav2lip, and structure component format
ctao456 d058496
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d6b3508
Merge branch 'opea-project:main' into ctao/opea
ctao456 ff0ec2d
Add dockerfiles in animation-compose-cd.yaml
ctao456 87f51e6
Fix end of file issue in animation-compose-cd.yaml
ctao456 3520b9e
Merge branch 'main' into ctao/opea
chensuyue c4f43da
Fix Docker deployment on Xeon
ctao456 f41f974
Merge branch 'ctao/opea' of https://github.com/ctao456/GenAIComps int…
ctao456 b7752b5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 22cc67a
add versioning for all pip packages
ctao456 fd214e7
e2e test script for animation
ctao456 48a23f6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a75bcc6
update e2e test script
ctao456 46d293e
Merge branch 'ctao/opea' of https://github.com/ctao456/GenAIComps int…
ctao456 f637e1e
update e2e test script
ctao456 a3e2148
Merge branch 'opea-project:main' into ctao/opea
ctao456 d9f152b
update readme
ctao456 e08f0fb
Merge branch 'ctao/opea' of https://github.com/ctao456/GenAIComps int…
ctao456 f2e6b34
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 72a6527
update
ctao456 dd849ef
update
ctao456 fecedab
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f3f3343
update gateway
ctao456 8790139
udpate gateway
ctao456 26deb88
Fix AVATAR_CHATBOT
ctao456 5d8fef8
update gateway
ctao456 a0b4d13
update
ctao456 9a705ca
test
ctao456 e177ba2
update
ctao456 d36d0fe
update
ctao456 e90f5cf
update gateway
ctao456 dda2e31
fix max_tokens in AvatarChatbot gateway
ctao456 83186de
test
ctao456 38e4d46
update
ctao456 7aa56f4
update
ctao456 155ef8e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
.github/workflows/docker/compose/animation-compose-cd.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # this file should be run in the root of the repo | ||
| # images used by GenAIExamples: animation, wav2lip, wav2lip-gaudi | ||
| services: | ||
| animation: | ||
| build: | ||
| dockerfile: comps/animation/wav2lip/Dockerfile | ||
| image: ${REGISTRY:-opea}/animation:${TAG:-latest} | ||
| wav2lip: | ||
| build: | ||
| dockerfile: comps/animation/wav2lip/dependency/Dockerfile | ||
| image: ${REGISTRY:-opea}/wav2lip:${TAG:-latest} | ||
| wav2lip-gaudi: | ||
| build: | ||
| dockerfile: comps/animation/wav2lip/dependency/Dockerfile.intel_hpu | ||
| image: ${REGISTRY:-opea}/wav2lip-gaudi:${TAG:-latest} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Use a base image | ||
| FROM python:3.11-slim | ||
|
|
||
| RUN useradd -m -s /bin/bash user && \ | ||
| mkdir -p /home/user && \ | ||
| chown -R user /home/user/ | ||
| USER user | ||
|
|
||
| ENV LANG=C.UTF-8 | ||
| ARG ARCH=cpu | ||
|
|
||
| COPY comps /home/user/comps | ||
|
|
||
| RUN pip install --no-cache-dir --upgrade pip && \ | ||
| pip install --no-cache-dir -r /home/user/comps/animation/requirements.txt ; | ||
|
|
||
| ENV PYTHONPATH=$PYTHONPATH:/home/user | ||
|
|
||
| WORKDIR /home/user/comps/animation | ||
|
|
||
| ENTRYPOINT ["python3", "animation.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Avatar Animation Microservice | ||
|
|
||
| The avatar animation model is a combination of two models: Wav2Lip and GAN-based face generator (GFPGAN). The Wav2Lip model is used to generate lip movements from an audio file, and the GFPGAN model is used to generate a high-quality face image from a low-quality face image. The avatar animation microservices takes an audio piece and a low-quality face image/video as input, fuses mel-spectrogram from the audio with frame(s) from the image/video, and generates a high-quality video of the face image with lip movements synchronized with the audio. | ||
|
|
||
| # 🚀1. Start Microservice with Docker (option 1) | ||
|
|
||
| ## 1.1 Build the Docker images | ||
|
|
||
| ### 1.1.1 Wav2Lip Server image | ||
|
|
||
| ```bash | ||
| git clone https://github.com/opea-project/GenAIComps.git | ||
| cd GenAIComps | ||
| ``` | ||
|
|
||
| - Xeon CPU | ||
|
|
||
| ```bash | ||
| docker build -t opea/wav2lip:latest -f comps/animation/dependency/Dockerfile . | ||
| ``` | ||
|
|
||
| - Gaudi2 HPU | ||
|
|
||
| ```bash | ||
| docker build -t opea/wav2lip-gaudi:latest -f comps/animation/dependency/Dockerfile.intel_hpu . | ||
| ``` | ||
|
|
||
| ### 1.1.2 Animation server image | ||
|
|
||
| ```bash | ||
| docker build -t opea/animation:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/animation/wav2lip/Dockerfile . | ||
| ``` | ||
|
|
||
| ## 1.2. Set environment variables | ||
|
|
||
| ```bash | ||
| export ip_address=$(hostname -I | awk '{print $1}') | ||
| # export DEVICE="cpu" | ||
| export DEVICE="hpu" | ||
| export WAV2LIP_PORT=7860 | ||
| export ANIMATION_PORT=9066 | ||
| export INFERENCE_MODE='wav2lip+gfpgan' | ||
| export CHECKPOINT_PATH='/usr/local/lib/python3.10/dist-packages/Wav2Lip/checkpoints/wav2lip_gan.pth' | ||
| export FACE='assets/avatar1.jpg' | ||
| # export AUDIO='assets/eg3_ref.wav' # audio file path is optional, will use base64str in the post request as input if is 'None' | ||
| export AUDIO='None' | ||
| export FACESIZE=96 | ||
| export OUTFILE="$(pwd)/comps/animation/wav2lip/assets/outputs/result.mp4" | ||
| export GFPGAN_MODEL_VERSION=1.3 | ||
| export UPSCALE_FACTOR=1 | ||
| export FPS=10 | ||
| ``` | ||
|
|
||
| # 🚀2. Run the Docker container | ||
|
|
||
| ## 2.1 Run Wav2Lip Microservice | ||
|
|
||
| - Xeon CPU | ||
|
|
||
| ```bash | ||
| docker run --privileged -d -p 7860:7860 --ipc=host --name "wav2lip-service" -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v $(pwd):$(pwd) -w /home/user/comps/animation -e PYTHON=/usr/bin/python3.11 -e DEVICE=$DEVICE -e INFERENCE_MODE=$INFERENCE_MODE -e CHECKPOINT_PATH=$CHECKPOINT_PATH -e FACE=$FACE -e AUDIO=$AUDIO -e FACESIZE=$FACESIZE -e OUTFILE=$OUTFILE -e GFPGAN_MODEL_VERSION=$GFPGAN_MODEL_VERSION -e UPSCALE_FACTOR=$UPSCALE_FACTOR -e FPS=$FPS -e WAV2LIP_PORT=$WAV2LIP_PORT opea/wav2lip:latest | ||
| ``` | ||
|
|
||
| - Gaudi2 HPU | ||
|
|
||
| ```bash | ||
| docker run --privileged -d --runtime=habana --cap-add=sys_nice --net=host --ipc=host --name "wav2lip-gaudi-service" -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v $(pwd):$(pwd) -w /home/user/comps/animation -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none -e PYTHON=/usr/bin/python3.10 -e DEVICE=$DEVICE -e INFERENCE_MODE=$INFERENCE_MODE -e CHECKPOINT_PATH=$CHECKPOINT_PATH -e FACE=$FACE -e AUDIO=$AUDIO -e FACESIZE=$FACESIZE -e OUTFILE=$OUTFILE -e GFPGAN_MODEL_VERSION=$GFPGAN_MODEL_VERSION -e UPSCALE_FACTOR=$UPSCALE_FACTOR -e FPS=$FPS -e WAV2LIP_PORT=$WAV2LIP_PORT opea/wav2lip-gaudi:latest | ||
| ``` | ||
|
|
||
| ## 2.2 Run Animation Microservice | ||
|
|
||
| ```bash | ||
| docker run -d -p 9066:9066 --ipc=host --name "animation-service" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e WAV2LIP_ENDPOINT=http://$ip_address:7860 opea/animation:latest | ||
| ``` | ||
|
|
||
| # 🚀3. Validate Microservice | ||
|
|
||
| Once microservice starts, user can use below script to validate the running microservice. | ||
|
|
||
| ## 3.1 Validate Wav2Lip service | ||
|
|
||
| ```bash | ||
| cd GenAIComps/comps/animation/wav2lip | ||
| python3 dependency/check_wav2lip_server.py | ||
| ``` | ||
|
|
||
| ## 3.2 Validate Animation service | ||
|
|
||
| ```bash | ||
| cd GenAIComps | ||
| export ip_address=$(hostname -I | awk '{print $1}') | ||
| curl http://${ip_address}:7860/v1/animation -X POST -H "Content-Type: application/json" -d @comps/animation/wav2lip/assets/audio/sample_question.json | ||
| ``` | ||
|
|
||
| or | ||
|
|
||
| ```bash | ||
| cd GenAIComps/comps/animation/wav2lip | ||
| python3 check_animation_server.py | ||
| ``` | ||
|
|
||
| The expected output is a message similar to the following: | ||
|
|
||
| ```bash | ||
| "Status code: 200" | ||
| "Check $OUTFILE for the result." | ||
| "{'id': '33dd8249228b0e011a33b449af9aa776', 'video_save_path': '.../GenAIComps/comps/animation/wav2lip/assets/outputs/result.mp4'}" | ||
| ``` | ||
|
|
||
| Please find "./outputs/result.mp4" as a reference generated video. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Copyright (c) 2013--2023, librosa development team. | ||
| # Copyright 1999-2003 The OpenLDAP Foundation, Redwood City, California, USA. All Rights Reserved. | ||
| # Copyright (c) 2012, Anaconda, Inc. All rights reserved. | ||
|
|
||
| import json | ||
| import os | ||
| import time | ||
|
|
||
| import requests | ||
|
|
||
| # GenAIComps | ||
| from comps import CustomLogger | ||
|
|
||
| logger = CustomLogger("animation") | ||
| logflag = os.getenv("LOGFLAG", False) | ||
| from comps import ( | ||
| Base64ByteStrDoc, | ||
| ServiceType, | ||
| VideoPath, | ||
| opea_microservices, | ||
| register_microservice, | ||
| register_statistics, | ||
| statistics_dict, | ||
| ) | ||
|
|
||
|
|
||
| # Register the microservice | ||
| @register_microservice( | ||
| name="opea_service@animation", | ||
| service_type=ServiceType.ANIMATION, | ||
| endpoint="/v1/animation", | ||
| host="0.0.0.0", | ||
| port=9066, | ||
| input_datatype=Base64ByteStrDoc, | ||
| output_datatype=VideoPath, | ||
| ) | ||
| @register_statistics(names=["opea_service@animation"]) | ||
| async def animate(audio: Base64ByteStrDoc): | ||
| start = time.time() | ||
|
|
||
| byte_str = audio.byte_str | ||
| inputs = {"audio": byte_str} | ||
| if logflag: | ||
| logger.info(inputs) | ||
|
|
||
| response = requests.post(url=f"{wav2lip_endpoint}/v1/wav2lip", data=json.dumps(inputs), proxies={"http": None}) | ||
|
|
||
| outfile = response.json()["wav2lip_result"] | ||
| if logflag: | ||
| logger.info(response) | ||
| logger.info(f"Video generated successfully, check {outfile} for the result.") | ||
|
|
||
| statistics_dict["opea_service@animation"].append_latency(time.time() - start, None) | ||
| return VideoPath(video_path=outfile) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| wav2lip_endpoint = os.getenv("WAV2LIP_ENDPOINT", "http://localhost:7860") | ||
| logger.info("[animation - router] Animation initialized.") | ||
| opea_microservices["opea_service@animation"].start() |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import json | ||
| import os | ||
|
|
||
| import requests | ||
|
|
||
| ip_address = os.environ.get("ip_address") | ||
| endpoint = f"http://{ip_address}:9066/v1/animation" | ||
| outfile = os.environ.get("OUTFILE") | ||
|
|
||
| # Read the JSON file | ||
| with open("assets/audio/sample_question.json", "r") as file: | ||
| data = json.load(file) | ||
|
|
||
| response = requests.post(url=endpoint, json=data, headers={"Content-Type": "application/json"}, proxies={"http": None}) | ||
| print(f"Status code: {response.status_code}") | ||
| if response.status_code == 200: | ||
| print(f"Check {outfile} for the result.") | ||
| print(response.json()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Use a base image | ||
| FROM python:3.11-slim | ||
|
|
||
| # Set environment variables | ||
| ENV LANG=en_US.UTF-8 | ||
| ENV PYTHONPATH=/home:/home/user | ||
| ENV PYTHON=/usr/bin/python3.11 | ||
|
|
||
| # Install dependencies | ||
| RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ | ||
| yasm \ | ||
| libx264-dev | ||
|
|
||
| # TO-DO: Add a user for security | ||
|
|
||
| # Install GenAIComps | ||
| RUN mkdir -p /home/user/comps | ||
| COPY comps /home/user/comps | ||
| COPY comps/animation/dependency/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
|
||
| # Install ppmpeg with x264 software codec | ||
| RUN git clone https://github.com/FFmpeg/FFmpeg.git /home/user/comps/animation/FFmpeg | ||
| WORKDIR /home/user/comps/animation/FFmpeg | ||
| RUN ./configure --enable-gpl --enable-libx264 && \ | ||
| make -j$(nproc-1) && \ | ||
| make install && \ | ||
| hash -r | ||
| RUN chmod +x $(which ffmpeg) | ||
|
|
||
| # Upgrade pip | ||
| RUN python3 -m pip install --upgrade pip | ||
|
|
||
| # Install Wav2Lip from pip | ||
| RUN pip install --no-deps Wav2Lipy | ||
| RUN rm /usr/local/lib/python3.10/dist-packages/Wav2Lip/__init__.py && touch /usr/local/lib/python3.10/dist-packages/Wav2Lip/__init__.py | ||
| ENV PYTHONPATH="/usr/local/lib/python3.10/dist-packages/Wav2Lip:$PYTHONPATH" | ||
|
|
||
| # Install GFPGAN from pip | ||
| RUN pip install --no-deps gfpgan | ||
| RUN touch /usr/local/lib/python3.10/dist-packages/gfpgan/__init__.py | ||
| ENV PYTHONPATH="/usr/local/lib/python3.10/dist-packages/gfpgan:$PYTHONPATH" | ||
|
|
||
| # Download pre-trained models | ||
| # Install gdown | ||
| RUN pip install gdown | ||
| WORKDIR /usr/local/lib/python3.10/dist-packages | ||
| # RUN wget https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth -O Wav2Lip/face_detection/detection/sfd/s3fd.pth | ||
| RUN gdown https://drive.google.com/uc?id=1wwts8U4Wx2lpLOI9uGcUB-TLmKRIFnP8 -O Wav2Lip/face_detection/detection/sfd/s3fd.pth | ||
ctao456 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RUN mkdir -p Wav2Lip/checkpoints | ||
| RUN gdown https://drive.google.com/uc?id=1mIKfu_onFKbkbrq6cKVRBblXe5bNMhd9 -O Wav2Lip/checkpoints/wav2lip.pth | ||
| RUN gdown https://drive.google.com/uc?id=1DD7dtUfNWqNoW-2Gnp78B4PyaiJ5ybhP -O Wav2Lip/checkpoints/wav2lip_gan.pth | ||
| RUN wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P gfpgan/experiments/pretrained_models | ||
|
|
||
| # Install pip dependencies | ||
| RUN pip install -r /home/user/comps/animation/requirements.txt | ||
|
|
||
| # Custom patches | ||
| # Modify the degradations.py file to import rgb_to_grayscale from torchvision.transforms.functional | ||
| RUN sed -i 's/from torchvision.transforms.functional_tensor import rgb_to_grayscale/from torchvision.transforms.functional import rgb_to_grayscale/' /usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py | ||
|
|
||
| # Modify the core.py file to include 'hpu' in the device check | ||
| RUN sed -i "s/if 'cpu' not in device and 'cuda' not in device:/if 'cpu' not in device and 'cuda' not in device and 'hpu' not in device:/" /usr/local/lib/python3.10/dist-packages/Wav2Lip/face_detection/detection/core.py | ||
|
|
||
| # To be compatible with librosa==0.10.2, instead of librosa==0.7.0 because the co-dependency numba==0.48 cannot be pip installed | ||
| RUN sed -i 's/hp.sample_rate, hp.n_fft/sr=hp.sample_rate, n_fft=hp.n_fft/' /usr/local/lib/python3.10/dist-packages/Wav2Lip/audio.py | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /home/user/comps/animation | ||
|
|
||
| # Define the command to run when the container starts | ||
| RUN chmod +x /usr/local/bin/entrypoint.sh | ||
| ENV DEVICE="cpu" | ||
| ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Use a base image | ||
| # FROM python:3.11-slim | ||
| FROM vault.habana.ai/gaudi-docker/1.16.2/ubuntu22.04/habanalabs/pytorch-installer-2.2.2:latest AS hpu | ||
|
|
||
| # Set environment variables | ||
| ENV LANG=en_US.UTF-8 | ||
| ENV PYTHONPATH=/home:/home/user:/usr/lib/habanalabs/:/optimum-habana | ||
| ENV PYTHON=/usr/bin/python3.10 | ||
|
|
||
| # Install dependencies | ||
| RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ | ||
| yasm \ | ||
| libx264-dev | ||
| RUN apt-get install -y nasm | ||
| RUN rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # TO-DO: Add a user for security | ||
|
|
||
| # Install GenAIComps | ||
| RUN mkdir -p /home/user/comps | ||
| COPY comps /home/user/comps | ||
| COPY comps/animation/dependency/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
|
||
| # Install ppmpeg with x264 software codec | ||
ctao456 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RUN git clone https://github.com/FFmpeg/FFmpeg.git /home/user/comps/animation/FFmpeg | ||
| WORKDIR /home/user/comps/animation/FFmpeg | ||
| RUN ./configure --enable-gpl --enable-libx264 && \ | ||
| make -j$(nproc-1) && \ | ||
| make install && \ | ||
| hash -r | ||
| RUN chmod +x $(which ffmpeg) | ||
|
|
||
| # Upgrade pip | ||
| RUN python3 -m pip install --upgrade pip | ||
|
|
||
| # Install Wav2Lip from pip | ||
| RUN pip install --no-deps Wav2Lipy | ||
| RUN rm /usr/local/lib/python3.10/dist-packages/Wav2Lip/__init__.py && touch /usr/local/lib/python3.10/dist-packages/Wav2Lip/__init__.py | ||
| ENV PYTHONPATH="/usr/local/lib/python3.10/dist-packages/Wav2Lip:$PYTHONPATH" | ||
|
|
||
| # Install GFPGAN from pip | ||
| RUN pip install --no-deps gfpgan | ||
| RUN touch /usr/local/lib/python3.10/dist-packages/gfpgan/__init__.py | ||
| ENV PYTHONPATH="/usr/local/lib/python3.10/dist-packages/gfpgan:$PYTHONPATH" | ||
|
|
||
| # Download pre-trained models | ||
| # Install gdown | ||
| RUN pip install gdown | ||
| WORKDIR /usr/local/lib/python3.10/dist-packages | ||
| # RUN wget https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth -O Wav2Lip/face_detection/detection/sfd/s3fd.pth | ||
ctao456 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RUN gdown https://drive.google.com/uc?id=1wwts8U4Wx2lpLOI9uGcUB-TLmKRIFnP8 -O Wav2Lip/face_detection/detection/sfd/s3fd.pth | ||
| RUN mkdir -p Wav2Lip/checkpoints | ||
| RUN gdown https://drive.google.com/uc?id=1mIKfu_onFKbkbrq6cKVRBblXe5bNMhd9 -O Wav2Lip/checkpoints/wav2lip.pth | ||
| RUN gdown https://drive.google.com/uc?id=1DD7dtUfNWqNoW-2Gnp78B4PyaiJ5ybhP -O Wav2Lip/checkpoints/wav2lip_gan.pth | ||
| RUN wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P gfpgan/experiments/pretrained_models | ||
|
|
||
| # Install pip dependencies | ||
| RUN pip install -r /home/user/comps/animation/requirements.txt | ||
|
|
||
| # Custom patches | ||
| # Modify the degradations.py file to import rgb_to_grayscale from torchvision.transforms.functional | ||
| RUN sed -i 's/from torchvision.transforms.functional_tensor import rgb_to_grayscale/from torchvision.transforms.functional import rgb_to_grayscale/' /usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py | ||
|
|
||
| # Modify the core.py file to include 'hpu' in the device check | ||
| RUN sed -i "s/if 'cpu' not in device and 'cuda' not in device:/if 'cpu' not in device and 'cuda' not in device and 'hpu' not in device:/" /usr/local/lib/python3.10/dist-packages/Wav2Lip/face_detection/detection/core.py | ||
|
|
||
| # To be compatible with librosa==0.10.2, instead of librosa==0.7.0 because the co-dependency numba==0.48 cannot be pip installed | ||
| RUN sed -i 's/hp.sample_rate, hp.n_fft/sr=hp.sample_rate, n_fft=hp.n_fft/' /usr/local/lib/python3.10/dist-packages/Wav2Lip/audio.py | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /home/user/comps/animation | ||
|
|
||
| # Define the command to run when the container starts | ||
| RUN chmod +x /usr/local/bin/entrypoint.sh | ||
| ENV DEVICE="hpu" | ||
| ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.