Skip to content

Commit

Permalink
Refactor animation/image2image/text2sql docker compose (#1218)
Browse files Browse the repository at this point in the history
* Refactor animation/image2image/text2sql docker compose

1. Unified docker compose format and reduce duplicate references
2. Use docker compose to test animation/image2image/text2sql



Signed-off-by: Yao, Qing <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
yao531441 and pre-commit-ci[bot] authored Jan 24, 2025
1 parent 293a588 commit 44fec2b
Show file tree
Hide file tree
Showing 11 changed files with 502 additions and 84 deletions.
41 changes: 41 additions & 0 deletions comps/animation/deployment/docker_compose/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

include:
- ../../../third_parties/wav2lip/deployment/docker_compose/compose.yaml

services:
animation:
image: ${REGISTRY:-opea}/animation:${TAG:-latest}
container_name: animation-server
ports:
- ${ANIMATION_PORT:-9066}:9066
ipc: host
environment:
no_proxy: ${no_proxy}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
WAV2LIP_ENDPOINT: ${WAV2LIP_ENDPOINT}
restart: unless-stopped
depends_on:
- wav2lip-server

animation-gaudi:
image: ${REGISTRY:-opea}/animation:${TAG:-latest}
container_name: animation-gaudi-server
ports:
- ${ANIMATION_PORT:-9066}:9066
ipc: host
environment:
no_proxy: ${no_proxy}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
HABANA_VISIBLE_DEVICES: all
OMPI_MCA_btl_vader_single_copy_mechanism: none
WAV2LIP_ENDPOINT: ${WAV2LIP_ENDPOINT}
runtime: habana
cap_add:
- SYS_NICE
restart: unless-stopped
depends_on:
- wav2lip-gaudi-server
40 changes: 40 additions & 0 deletions comps/image2image/deployment/docker_compose/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

services:
image2image:
image: ${REGISTRY:-opea}/image2image:${TAG:-latest}
container_name: image2image-server
ports:
- ${IMAGE2IMAGE_PORT:-9389}:9389
ipc: host
environment:
no_proxy: ${no_proxy}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
HF_TOKEN: ${HF_TOKEN}
MODEL: ${MODEL}
restart: unless-stopped

image2image-gaudi:
image: ${REGISTRY:-opea}/image2image-gaudi:${TAG:-latest}
container_name: image2image-gaudi-server
ports:
- ${IMAGE2IMAGE_PORT:-9389}:9389
ipc: host
environment:
no_proxy: ${no_proxy}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
HF_TOKEN: ${HF_TOKEN}
MODEL: ${MODEL}
HABANA_VISIBLE_DEVICES: all
OMPI_MCA_btl_vader_single_copy_mechanism: none
runtime: habana
cap_add:
- SYS_NICE
restart: unless-stopped

networks:
default:
driver: bridge
44 changes: 44 additions & 0 deletions comps/text2sql/deployment/docker_compose/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

include:
- ../../../third_parties/tgi/deployment/docker_compose/compose.yaml

services:
postgres:
image: postgres:latest
container_name: postgres-container
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
ports:
- '5442:5432'
volumes:
- ../../src/chinook.sql:/docker-entrypoint-initdb.d/chinook.sql

text2sql:
image: opea/text2sql:${TAG:-latest}
container_name: text2sql-server
ports:
- ${TEXT2SQL_PORT:-9090}:8080
environment:
- TGI_LLM_ENDPOINT=${TGI_LLM_ENDPOINT}
depends_on:
- tgi-server
- postgres

text2sql-gaudi:
image: opea/text2sql:${TAG:-latest}
container_name: text2sql-gaudi-server
ports:
- ${TEXT2SQL_PORT:-9090}:8080
environment:
- TGI_LLM_ENDPOINT=${TGI_LLM_ENDPOINT}
depends_on:
- tgi-gaudi-server
- postgres
networks:
default:
driver: bridge
46 changes: 0 additions & 46 deletions comps/text2sql/deployment/docker_compose/langchain.yaml

This file was deleted.

61 changes: 61 additions & 0 deletions comps/third_parties/wav2lip/deployment/docker_compose/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

services:
wav2lip-server:
image: ${REGISTRY:-opea}/wav2lip:${TAG:-latest}
container_name: wav2lip-server
ports:
- ${WAV2LIP_PORT:-7860}:${WAV2LIP_PORT:-7860}
ipc: host
volumes:
- ${PWD}:/outputs
environment:
no_proxy: ${no_proxy}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
DEVICE: ${DEVICE}
INFERENCE_MODE: ${INFERENCE_MODE}
CHECKPOINT_PATH: ${CHECKPOINT_PATH}
FACE: ${FACE}
AUDIO: ${AUDIO}
FACESIZE: ${FACESIZE}
OUTFILE: ${OUTFILE}
GFPGAN_MODEL_VERSION: ${GFPGAN_MODEL_VERSION}
UPSCALE_FACTOR: ${UPSCALE_FACTOR}
FPS: ${FPS}
WAV2LIP_PORT: ${WAV2LIP_PORT:-7860}
restart: unless-stopped
wav2lip-gaudi-server:
image: ${REGISTRY:-opea}/wav2lip-gaudi:${TAG:-latest}
container_name: wav2lip-gaudi-server
ports:
- ${WAV2LIP_PORT:-7860}:${WAV2LIP_PORT:-7860}
ipc: host
volumes:
- ${PWD}:/outputs
environment:
no_proxy: ${no_proxy}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
HABANA_VISIBLE_DEVICES: all
OMPI_MCA_btl_vader_single_copy_mechanism: none
DEVICE: ${DEVICE}
INFERENCE_MODE: ${INFERENCE_MODE}
CHECKPOINT_PATH: ${CHECKPOINT_PATH}
FACE: ${FACE}
AUDIO: ${AUDIO}
FACESIZE: ${FACESIZE}
OUTFILE: ${OUTFILE}
GFPGAN_MODEL_VERSION: ${GFPGAN_MODEL_VERSION}
UPSCALE_FACTOR: ${UPSCALE_FACTOR}
FPS: ${FPS}
WAV2LIP_PORT: ${WAV2LIP_PORT}
runtime: habana
cap_add:
- SYS_NICE
restart: unless-stopped

networks:
default:
driver: bridge
31 changes: 18 additions & 13 deletions tests/animation/test_animation_wav2lip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ set -x
WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')

export TAG=comps
export ANIMATION_PORT=10900
export WAV2LIP_PORT=12300
export service_name="animation"


function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build -t opea/wav2lip:comps -f comps/third_parties/wav2lip/src/Dockerfile .
docker build -t opea/wav2lip:$TAG -f comps/third_parties/wav2lip/src/Dockerfile .
if [ $? -ne 0 ]; then
echo "opea/wav2lip built fail"
exit 1
else
echo "opea/wav2lip built successful"
fi
docker build --no-cache -t opea/animation:comps -f comps/animation/src/Dockerfile .
docker build --no-cache -t opea/animation:$TAG -f comps/animation/src/Dockerfile .
if [ $? -ne 0 ]; then
echo "opea/animation built fail"
exit 1
Expand All @@ -31,8 +37,6 @@ function start_service() {
# Set env vars
export ip_address=$(hostname -I | awk '{print $1}')
export DEVICE="cpu"
export WAV2LIP_PORT=7860
export ANIMATION_PORT=9066
export INFERENCE_MODE='wav2lip+gfpgan'
export CHECKPOINT_PATH='/usr/local/lib/python3.11/site-packages/Wav2Lip/checkpoints/wav2lip_gan.pth'
export FACE="/home/user/comps/animation/src/assets/img/avatar1.jpg"
Expand All @@ -42,28 +46,30 @@ function start_service() {
export GFPGAN_MODEL_VERSION=1.4 # latest version, can roll back to v1.3 if needed
export UPSCALE_FACTOR=1
export FPS=10
export WAV2LIP_ENDPOINT="http://$ip_address:$WAV2LIP_PORT"

cd $WORKPATH/comps/animation/deployment/docker_compose
docker compose -f compose.yaml up ${service_name} -d

docker run -d --name="test-comps-animation-wav2lip" -v $WORKPATH/comps/animation/src/assets:/home/user/comps/animation/src/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
docker run -d --name="test-comps-animation" -v $WORKPATH/comps/animation/src/assets:/home/user/comps/animation/src/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
sleep 3m
}

function validate_microservice() {
cd $WORKPATH
result=$(http_proxy="" curl http://localhost:9066/v1/animation -X POST -H "Content-Type: application/json" -d @comps/animation/src/assets/audio/sample_question.json)
result=$(http_proxy="" curl http://localhost:$ANIMATION_PORT/v1/animation -X POST -H "Content-Type: application/json" -d @comps/animation/src/assets/audio/sample_question.json)
if [[ $result == *"result.mp4"* ]]; then
echo "Result correct."
else
echo "Result wrong."
docker logs test-comps-animation-wav2lip
docker logs test-comps-animation
docker logs wav2lip-server
docker logs animation-server
exit 1
fi
}

function stop_docker() {
cid=$(docker ps -aq --filter "name=test-comps-animation*")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
cd $WORKPATH/comps/animation/deployment/docker_compose
docker compose -f compose.yaml down ${service_name} --remove-orphans
}

function main() {
Expand All @@ -77,8 +83,7 @@ function main() {

stop_docker

echo y | docker builder prune --all
echo y | docker image prune
echo y | docker system prune

}

Expand Down
Loading

0 comments on commit 44fec2b

Please sign in to comment.