|
| 1 | +# Deploying Avatar Animation Service |
| 2 | + |
| 3 | +This document provides a comprehensive guide to deploying the Avatar Animation microservice pipeline on Intel platforms. |
| 4 | + |
| 5 | +This guide covers two deployment methods: |
| 6 | + |
| 7 | +- [🚀 1. Quick Start with Docker Compose](#-1-quick-start-with-docker-compose): The recommended method for a fast and easy setup. |
| 8 | +- [🚀 2. Manual Step-by-Step Deployment (Advanced)](#-2-manual-step-by-step-deployment-advanced): For users who want to build and run each container individually. |
| 9 | + |
| 10 | +## 🚀 1. Quick Start with Docker Compose |
| 11 | + |
| 12 | +This method uses Docker Compose to start all necessary services with a single command. It is the fastest and easiest way to get the service running. |
| 13 | + |
| 14 | +### 1.1. Access the Code |
| 15 | + |
| 16 | +Clone the repository and navigate to the deployment directory: |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/opea-project/GenAIComps.git |
| 20 | +cd GenAIComps/comps/animation/deployment/docker_compose |
| 21 | +``` |
| 22 | + |
| 23 | +### 1.2. Deploy the Service |
| 24 | + |
| 25 | +Choose the command corresponding to your target platform. |
| 26 | + |
| 27 | +- **For Intel® Xeon® CPU:** |
| 28 | + |
| 29 | + ```bash |
| 30 | + docker compose -f compose.yaml up animation -d |
| 31 | + ``` |
| 32 | + |
| 33 | +- **For Intel® Gaudi® 2 HPU:** |
| 34 | + ```bash |
| 35 | + docker compose -f compose.yaml up animation-gaudi -d |
| 36 | + ``` |
| 37 | + |
| 38 | +### 1.3. Validate the Service |
| 39 | + |
| 40 | +Once the containers are running, you can validate the service. **Note:** Run these commands from the root of the `GenAIComps` repository. |
| 41 | + |
| 42 | +```bash |
| 43 | +# Navigate back to the root directory if you are in the docker_compose folder |
| 44 | +cd ../../.. |
| 45 | + |
| 46 | +# Validate the Animation service endpoint |
| 47 | +export ip_address=$(hostname -I | awk '{print $1}') |
| 48 | +curl http://${ip_address}:9066/v1/animation -X POST \ |
| 49 | +-H "Content-Type: application/json" \ |
| 50 | +-d @comps/animation/src/assets/audio/sample_question.json |
| 51 | +``` |
| 52 | + |
| 53 | +The expected output will be a JSON object containing the path to the generated video file: |
| 54 | + |
| 55 | +```json |
| 56 | +{ "wav2lip_result": ".../GenAIComps/comps/animation/src/assets/outputs/result.mp4" } |
| 57 | +``` |
| 58 | + |
| 59 | +The generated video `result.mp4` will be available in the `comps/animation/src/assets/outputs/` directory. |
| 60 | + |
| 61 | +### 1.4. Clean Up the Deployment |
| 62 | + |
| 63 | +To stop and remove the containers, run the following command from the `comps/animation/deployment/docker_compose` directory: |
| 64 | + |
| 65 | +```bash |
| 66 | +docker compose down |
| 67 | +``` |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## 🚀 2. Manual Step-by-Step Deployment (Advanced) |
| 72 | + |
| 73 | +This section provides detailed instructions for building the Docker images and running each microservice container individually. |
| 74 | + |
| 75 | +### 2.1. Clone the Repository |
| 76 | + |
| 77 | +If you haven't already, clone the repository and navigate to the root directory: |
| 78 | + |
| 79 | +```bash |
| 80 | +git clone https://github.com/opea-project/GenAIComps.git |
| 81 | +cd GenAIComps |
| 82 | +``` |
| 83 | + |
| 84 | +### 2.2. Build the Docker Images |
| 85 | + |
| 86 | +#### 2.2.1. Build Wav2Lip Server Image |
| 87 | + |
| 88 | +- **For Intel® Xeon® CPU:** |
| 89 | + ```bash |
| 90 | + docker build -t opea/wav2lip:latest -f comps/third_parties/wav2lip/src/Dockerfile . |
| 91 | + ``` |
| 92 | +- **For Intel® Gaudi® 2 HPU:** |
| 93 | + ```bash |
| 94 | + docker build -t opea/wav2lip-gaudi:latest -f comps/third_parties/wav2lip/src/Dockerfile.intel_hpu . |
| 95 | + ``` |
| 96 | + |
| 97 | +#### 2.2.2. Build Animation Server Image |
| 98 | + |
| 99 | +```bash |
| 100 | +docker build -t opea/animation:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/animation/src/Dockerfile . |
| 101 | +``` |
| 102 | + |
| 103 | +### 2.3. Configure Environment Variables |
| 104 | + |
| 105 | +Set the necessary environment variables for the containers. |
| 106 | + |
| 107 | +- **For Intel® Xeon® CPU:** |
| 108 | + |
| 109 | + ```bash |
| 110 | + export ip_address=$(hostname -I | awk '{print $1}') |
| 111 | + export DEVICE="cpu" |
| 112 | + export WAV2LIP_PORT=7860 |
| 113 | + export CHECKPOINT_PATH='/usr/local/lib/python3.11/site-packages/Wav2Lip/checkpoints/wav2lip_gan.pth' |
| 114 | + export PYTHON_PATH='/usr/bin/python3.11' |
| 115 | + ``` |
| 116 | + |
| 117 | +- **For Intel® Gaudi® 2 HPU:** |
| 118 | + ```bash |
| 119 | + export ip_address=$(hostname -I | awk '{print $1}') |
| 120 | + export DEVICE="hpu" |
| 121 | + export WAV2LIP_PORT=7860 |
| 122 | + export CHECKPOINT_PATH='/usr/local/lib/python3.10/dist-packages/Wav2Lip/checkpoints/wav2lip_gan.pth' |
| 123 | + export PYTHON_PATH='/usr/bin/python3.10' |
| 124 | + ``` |
| 125 | + |
| 126 | +### 2.4. Run the Microservice Containers |
| 127 | + |
| 128 | +#### 2.4.1. Run Wav2Lip Microservice |
| 129 | + |
| 130 | +- **For Intel® Xeon® CPU:** |
| 131 | + |
| 132 | + ```bash |
| 133 | + docker run --privileged -d --name "wav2lip-service" -p $WAV2LIP_PORT:$WAV2LIP_PORT --ipc=host \ |
| 134 | + -w /home/user/comps/animation/src \ |
| 135 | + -v $(pwd)/comps/animation/src/assets:/home/user/comps/animation/src/assets \ |
| 136 | + -e PYTHON=$PYTHON_PATH \ |
| 137 | + -e DEVICE=$DEVICE \ |
| 138 | + -e CHECKPOINT_PATH=$CHECKPOINT_PATH \ |
| 139 | + -e WAV2LIP_PORT=$WAV2LIP_PORT \ |
| 140 | + opea/wav2lip:latest |
| 141 | + ``` |
| 142 | + |
| 143 | +- **For Intel® Gaudi® 2 HPU:** |
| 144 | + ```bash |
| 145 | + docker run --privileged -d --name "wav2lip-gaudi-service" -p $WAV2LIP_PORT:$WAV2LIP_PORT --runtime=habana --cap-add=sys_nice --ipc=host \ |
| 146 | + -w /home/user/comps/animation/src \ |
| 147 | + -v $(pwd)/comps/animation/src/assets:/home/user/comps/animation/src/assets \ |
| 148 | + -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none \ |
| 149 | + -e PYTHON=$PYTHON_PATH \ |
| 150 | + -e DEVICE=$DEVICE \ |
| 151 | + -e CHECKPOINT_PATH=$CHECKPOINT_PATH \ |
| 152 | + -e WAV2LIP_PORT=$WAV2LIP_PORT \ |
| 153 | + opea/wav2lip-gaudi:latest |
| 154 | + ``` |
| 155 | + |
| 156 | +#### 2.4.2. Run Animation Microservice |
| 157 | + |
| 158 | +```bash |
| 159 | +docker run -d --name "animation-service" -p 9066:9066 --ipc=host \ |
| 160 | + -e http_proxy=$http_proxy \ |
| 161 | + -e https_proxy=$https_proxy \ |
| 162 | + -e WAV2LIP_ENDPOINT=http://$ip_address:$WAV2LIP_PORT \ |
| 163 | + opea/animation:latest |
| 164 | +``` |
| 165 | + |
| 166 | +### 2.5. Validate the Service |
| 167 | + |
| 168 | +After starting both containers, test the animation service endpoint. Make sure you are in the root directory of the `GenAIComps` repository. |
| 169 | + |
| 170 | +```bash |
| 171 | +# The ip_address variable should be set from step 2.3 |
| 172 | +curl http://${ip_address}:9066/v1/animation -X POST \ |
| 173 | +-H "Content-Type: application/json" \ |
| 174 | +-d @comps/animation/src/assets/audio/sample_question.json |
| 175 | +``` |
| 176 | + |
| 177 | +You should see a successful response with the path to the output video. |
| 178 | + |
| 179 | +### 2.6. Clean Up the Deployment |
| 180 | + |
| 181 | +To stop and remove the containers you started manually, use the `docker stop` and `docker rm` commands. |
| 182 | + |
| 183 | +- **For Intel® Xeon® CPU:** |
| 184 | + |
| 185 | + ```bash |
| 186 | + docker stop wav2lip-service animation-service |
| 187 | + docker rm wav2lip-service animation-service |
| 188 | + ``` |
| 189 | + |
| 190 | +- **For Intel® Gaudi® 2 HPU:** |
| 191 | + ```bash |
| 192 | + docker stop wav2lip-gaudi-service animation-service |
| 193 | + docker rm wav2lip-gaudi-service animation-service |
| 194 | + ``` |
0 commit comments