Skip to content

Commit aea7364

Browse files
ctao456hteeyeohXinyuYe-Intelpre-commit-ci[bot]ZePan110
authored
Move Wav2Lip model download commands from Dockerfiles to entrypoint.sh (opea-project#811)
* Update audioqna gateway to print text, in gateway.py Signed-off-by: Chun Tao <[email protected]> * updates needed for demo Signed-off-by: Chun Tao <[email protected]> * original pr content Signed-off-by: Chun Tao <[email protected]> * Revert "updates needed for demo" This reverts commit f0c7a02. Signed-off-by: Chun Tao <[email protected]> * remove improper images Signed-off-by: Chun Tao <[email protected]> * Addressed some comments on previous pr Signed-off-by: Chun Tao <[email protected]> * Add Dockerfile for cpu support Signed-off-by: Chun Tao <[email protected]> * CODEOWNER: Update comp CODEOWNER (opea-project#757) Signed-off-by: Yeoh, Hoong Tee <[email protected]> Signed-off-by: Chun Tao <[email protected]> * Add stable diffusion microservice (opea-project#729) * add stable diffusion microservice. Signed-off-by: Ye, Xinyu <[email protected]> * added test. Signed-off-by: Ye, Xinyu <[email protected]> * changed output to images bytes data Signed-off-by: Ye, Xinyu <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * unified inference and wrapper into one microservice. Signed-off-by: Ye, Xinyu <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix test. Signed-off-by: Ye, Xinyu <[email protected]> --------- Signed-off-by: Ye, Xinyu <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Signed-off-by: Chun Tao <[email protected]> * Compatible with different platforms. (opea-project#766) * Compatible with different platforms. Signed-off-by: ZePan110 <[email protected]> * Fix issue. Signed-off-by: ZePan110 <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix issue Signed-off-by: ZePan110 <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: ZePan110 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Signed-off-by: Chun Tao <[email protected]> * Optimize path and link validity check. (opea-project#745) Signed-off-by: ZePan110 <[email protected]> Signed-off-by: Chun Tao <[email protected]> * Add timeout for ut test (opea-project#773) Signed-off-by: chensuyue <[email protected]> Signed-off-by: Chun Tao <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Chun Tao <[email protected]> * test hyperlink Signed-off-by: Chun Tao <[email protected]> * test hyperlink Signed-off-by: Chun Tao <[email protected]> * test hyperlink issue Signed-off-by: Chun Tao <[email protected]> * test hyperlink issue Signed-off-by: Chun Tao <[email protected]> * put back hyperlinks in readme Signed-off-by: Chun Tao <[email protected]> * remove possible error hyperlink Signed-off-by: Chun Tao <[email protected]> * put hyperlink back Signed-off-by: Chun Tao <[email protected]> * major update to use FastAPI for wav2lip, and structure component format Signed-off-by: Chun Tao <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add dockerfiles in animation-compose-cd.yaml Signed-off-by: Chun Tao <[email protected]> * Fix end of file issue in animation-compose-cd.yaml Signed-off-by: Chun Tao <[email protected]> * Fix Docker deployment on Xeon Signed-off-by: Chun Tao <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add versioning for all pip packages Signed-off-by: Chun Tao <[email protected]> * e2e test script for animation Signed-off-by: Chun Tao <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update e2e test script Signed-off-by: Chun Tao <[email protected]> * update e2e test script Signed-off-by: Chun Tao <[email protected]> * update readme Signed-off-by: Chun Tao <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update Signed-off-by: Chun Tao <[email protected]> * update Signed-off-by: Chun Tao <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update gateway Signed-off-by: Chun Tao <[email protected]> * udpate gateway Signed-off-by: Chun Tao <[email protected]> * Fix AVATAR_CHATBOT Signed-off-by: Chun Tao <[email protected]> * update gateway Signed-off-by: Chun Tao <[email protected]> * update Signed-off-by: Chun Tao <[email protected]> * test Signed-off-by: Chun Tao <[email protected]> * update Signed-off-by: Chun Tao <[email protected]> * update Signed-off-by: Chun Tao <[email protected]> * update gateway Signed-off-by: Chun Tao <[email protected]> * fix max_tokens in AvatarChatbot gateway Signed-off-by: Chun Tao <[email protected]> * test Signed-off-by: Chun Tao <[email protected]> * update Signed-off-by: Chun Tao <[email protected]> * update Signed-off-by: Chun Tao <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Model download script moved from Dockerfiles to Docker entrypoint Signed-off-by: Chun Tao <[email protected]> * update paths Signed-off-by: Chun Tao <[email protected]> * Correct paths in readme Signed-off-by: Chun Tao <[email protected]> * revert changes to audioqna gateway Signed-off-by: Chun Tao <[email protected]> * longer wait time after docker run Signed-off-by: Chun Tao <[email protected]> * add mount volume in test scripts Signed-off-by: Chun Tao <[email protected]> * add volume mount in test scripts Signed-off-by: Chun Tao <[email protected]> * udpate test script Signed-off-by: Chun Tao <[email protected]> --------- Signed-off-by: Chun Tao <[email protected]> Signed-off-by: Yeoh, Hoong Tee <[email protected]> Signed-off-by: Ye, Xinyu <[email protected]> Signed-off-by: ZePan110 <[email protected]> Signed-off-by: chensuyue <[email protected]> Co-authored-by: Hoong Tee, Yeoh <[email protected]> Co-authored-by: XinyuYe-Intel <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: ZePan110 <[email protected]> Co-authored-by: chen, suyue <[email protected]>
1 parent f36ca80 commit aea7364

File tree

8 files changed

+34
-22
lines changed

8 files changed

+34
-22
lines changed

comps/animation/wav2lip/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ export WAV2LIP_PORT=7860
4242
export ANIMATION_PORT=9066
4343
export INFERENCE_MODE='wav2lip+gfpgan'
4444
export CHECKPOINT_PATH='/usr/local/lib/python3.11/site-packages/Wav2Lip/checkpoints/wav2lip_gan.pth'
45-
export FACE="comps/animation/wav2lip/assets/img/avatar1.jpg"
45+
export FACE="assets/img/avatar1.jpg"
4646
# export AUDIO='assets/audio/eg3_ref.wav' # audio file path is optional, will use base64str in the post request as input if is 'None'
4747
export AUDIO='None'
4848
export FACESIZE=96
49-
export OUTFILE="comps/animation/wav2lip/assets/outputs/result.mp4"
49+
export OUTFILE="assets/outputs/result.mp4"
5050
export GFPGAN_MODEL_VERSION=1.4 # latest version, can roll back to v1.3 if needed
5151
export UPSCALE_FACTOR=1
5252
export FPS=10
@@ -61,11 +61,11 @@ export WAV2LIP_PORT=7860
6161
export ANIMATION_PORT=9066
6262
export INFERENCE_MODE='wav2lip+gfpgan'
6363
export CHECKPOINT_PATH='/usr/local/lib/python3.10/dist-packages/Wav2Lip/checkpoints/wav2lip_gan.pth'
64-
export FACE="comps/animation/wav2lip/assets/img/avatar1.jpg"
64+
export FACE="assets/img/avatar1.jpg"
6565
# export AUDIO='assets/audio/eg3_ref.wav' # audio file path is optional, will use base64str in the post request as input if is 'None'
6666
export AUDIO='None'
6767
export FACESIZE=96
68-
export OUTFILE="comps/animation/wav2lip/assets/outputs/result.mp4"
68+
export OUTFILE="assets/outputs/result.mp4"
6969
export GFPGAN_MODEL_VERSION=1.4 # latest version, can roll back to v1.3 if needed
7070
export UPSCALE_FACTOR=1
7171
export FPS=10
@@ -78,13 +78,13 @@ export FPS=10
7878
- Xeon CPU
7979

8080
```bash
81-
docker run --privileged -d --name "wav2lip-service" -p 7860:7860 --ipc=host -w /home/user/comps/animation/wav2lip -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
81+
docker run --privileged -d --name "wav2lip-service" -p 7860:7860 --ipc=host -w /home/user/comps/animation/wav2lip -e PYTHON=/usr/bin/python3.11 -v $(pwd)/comps/animation/wav2lip/assets:/home/user/comps/animation/wav2lip/assets -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
8282
```
8383

8484
- Gaudi2 HPU
8585

8686
```bash
87-
docker run --privileged -d --name "wav2lip-gaudi-service" -p 7860:7860 --runtime=habana --cap-add=sys_nice --net=host --ipc=host -w /home/user/comps/animation/wav2lip -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
87+
docker run --privileged -d --name "wav2lip-gaudi-service" -p 7860:7860 --runtime=habana --cap-add=sys_nice --net=host --ipc=host -w /home/user/comps/animation/wav2lip -v $(pwd)/comps/animation/wav2lip/assets:/home/user/comps/animation/wav2lip/assets -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
8888
```
8989

9090
## 2.2 Run Animation Microservice
@@ -100,8 +100,8 @@ Once microservice starts, user can use below script to validate the running micr
100100
## 3.1 Validate Wav2Lip service
101101

102102
```bash
103-
cd GenAIComps/comps/animation/wav2lip
104-
python3 dependency/check_wav2lip_server.py
103+
cd GenAIComps
104+
python3 comps/animation/wav2lip/dependency/check_wav2lip_server.py
105105
```
106106

107107
## 3.2 Validate Animation service
@@ -115,14 +115,14 @@ curl http://${ip_address}:9066/v1/animation -X POST -H "Content-Type: applicatio
115115
or
116116

117117
```bash
118-
cd GenAIComps/comps/animation/wav2lip
119-
python3 check_animation_server.py
118+
cd GenAIComps
119+
python3 comps/animation/wav2lip/dependency/check_animation_server.py
120120
```
121121

122122
The expected output is a message similar to the following:
123123

124124
```bash
125-
{'wav2lip_result': '.../GenAIComps/comps/animation/wav2lip/assets/outputs/result.mp4'}
125+
{'wav2lip_result': '....../GenAIComps/comps/animation/wav2lip/assets/outputs/result.mp4'}
126126
```
127127

128128
Please find "comps/animation/wav2lip/assets/outputs/result.mp4" as a reference generated video.
-124 Bytes
Binary file not shown.

comps/animation/wav2lip/check_animation_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
outfile = os.environ.get("OUTFILE")
1212

1313
# Read the JSON file
14-
with open("assets/audio/sample_question.json", "r") as file:
14+
with open("comps/animation/wav2lip/assets/audio/sample_question.json", "r") as file:
1515
data = json.load(file)
1616

1717
response = requests.post(url=endpoint, json=data, headers={"Content-Type": "application/json"}, proxies={"http": None})

comps/animation/wav2lip/dependency/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ ENV PYTHONPATH="$PYTHONPATH:/usr/local/lib/python3.11/site-packages/gfpgan"
5151

5252
# Download pre-trained models
5353
WORKDIR /usr/local/lib/python3.11/site-packages
54-
RUN chmod +x /home/user/comps/animation/wav2lip/dependency/download_ckpts.sh
55-
RUN /home/user/comps/animation/wav2lip/dependency/download_ckpts.sh
5654

5755
# Install pip dependencies
5856
RUN pip install -r /home/user/comps/animation/wav2lip/requirements.txt

comps/animation/wav2lip/dependency/Dockerfile.intel_hpu

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ ENV PYTHONPATH="$PYTHONPATH:/usr/local/lib/python3.10/dist-packages/gfpgan"
4545

4646
# Download pre-trained models
4747
WORKDIR /usr/local/lib/python3.10/dist-packages
48-
RUN chmod +x /home/user/comps/animation/wav2lip/dependency/download_ckpts.sh
49-
RUN /home/user/comps/animation/wav2lip/dependency/download_ckpts.sh
5048

5149
# Install pip dependencies
5250
RUN pip install -r /home/user/comps/animation/wav2lip/requirements.txt

comps/animation/wav2lip/dependency/check_wav2lip_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
outfile = os.environ.get("OUTFILE")
1111

1212
# Read the JSON file
13-
with open("assets/audio/sample_question.json", "r") as file:
13+
with open("comps/animation/wav2lip/assets/audio/sample_question.json", "r") as file:
1414
data = json.load(file)
1515

1616
inputs = {"audio": data["byte_str"]}

comps/animation/wav2lip/dependency/entrypoint.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
#!/bin/sh
2-
cd /home/user/comps/animation/wav2lip/ || exit
32

43
# Copyright (C) 2024 Intel Corporation
54
# SPDX-License-Identifier: Apache-2.0
65

6+
# Check the value of $DEVICE and cd to the download path accordingly
7+
if [ "$DEVICE" = "hpu" ]; then
8+
cd /usr/local/lib/python3.10/dist-packages
9+
else
10+
cd /usr/local/lib/python3.11/site-packages
11+
fi
12+
13+
# Download model weights
14+
wget https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth -O Wav2Lip/face_detection/detection/sfd/s3fd.pth
15+
mkdir -p Wav2Lip/checkpoints
16+
wget "https://iiitaphyd-my.sharepoint.com/:f:/g/personal/radrabha_m_research_iiit_ac_in/Eb3LEzbfuKlJiR600lQWRxgBIY27JZg80f7V9jtMfbNDaQ?download=1" -O Wav2Lip/checkpoints/wav2lip.pth
17+
wget "https://iiitaphyd-my.sharepoint.com/:f:/g/personal/radrabha_m_research_iiit_ac_in/EdjI7bZlgApMqsVoEUUXpLsBxqXbn5z8VTmoxp55YNDcIA?download=1" -O Wav2Lip/checkpoints/wav2lip_gan.pth
18+
wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -P gfpgan/experiments/pretrained_models
19+
echo "Face Detector, Wav2Lip, GFPGAN weights downloaded."
20+
721
# Environment variables
822
export PT_HPU_LAZY_MODE=0
923
export PT_HPU_ENABLE_REFINE_DYNAMIC_SHAPES=1
1024

1125
# Wav2Lip, GFPGAN
26+
cd /home/user/comps/animation/wav2lip/ || exit
1227
python3 dependency/wav2lip_server.py \
1328
--device $DEVICE \
1429
--port $((WAV2LIP_PORT)) \

tests/animation/test_animation_wav2lip.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function build_docker_images() {
1717
else
1818
echo "opea/wav2lip built successful"
1919
fi
20-
docker build -t opea/animation:comps -f comps/animation/wav2lip/Dockerfile .
20+
docker build --no-cache -t opea/animation:comps -f comps/animation/wav2lip/Dockerfile .
2121
if [ $? -ne 0 ]; then
2222
echo "opea/animation built fail"
2323
exit 1
@@ -43,12 +43,13 @@ function start_service() {
4343
export UPSCALE_FACTOR=1
4444
export FPS=10
4545

46-
docker run -d --name="test-comps-animation-wav2lip" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -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 -p 7860:7860 --ipc=host opea/wav2lip:comps
47-
docker run -d --name="test-comps-animation" -e WAV2LIP_ENDPOINT=http://$ip_address:7860 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 9066:9066 --ipc=host opea/animation:comps
48-
sleep 1m
46+
docker run -d --name="test-comps-animation-wav2lip" -v $WORKPATH/comps/animation/wav2lip/assets:/home/user/comps/animation/wav2lip/assets -e http_proxy=$http_proxy -e https_proxy=$https_proxy -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 -p 7860:7860 --ipc=host opea/wav2lip:comps
47+
docker run -d --name="test-comps-animation" -v $WORKPATH/comps/animation/wav2lip/assets:/home/user/comps/animation/wav2lip/assets -e WAV2LIP_ENDPOINT=http://$ip_address:7860 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 9066:9066 --ipc=host opea/animation:comps
48+
sleep 3m
4949
}
5050

5151
function validate_microservice() {
52+
cd $WORKPATH
5253
result=$(http_proxy="" curl http://localhost:9066/v1/animation -X POST -H "Content-Type: application/json" -d @comps/animation/wav2lip/assets/audio/sample_question.json)
5354
if [[ $result == *"result.mp4"* ]]; then
5455
echo "Result correct."

0 commit comments

Comments
 (0)