Skip to content

Commit c476343

Browse files
authored
Fix VideoQnA (opea-project#1696)
This PR fixes the VideoQnA example. Fixes Issues opea-project#1476 opea-project#1478 opea-project#1477 Signed-off-by: zhanmyz <[email protected]> Signed-off-by: Lacewell, Chaunte W <[email protected]>
1 parent 58b47c1 commit c476343

File tree

6 files changed

+310
-133
lines changed

6 files changed

+310
-133
lines changed

VideoQnA/docker_compose/intel/cpu/xeon/README.md

+73-46
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Port 8001 - Open to 0.0.0.0/0
1717
1818
embedding
1919
=========
20-
Port 6000 - Open to 0.0.0.0/0
20+
Port 6990 - Open to 0.0.0.0/0
2121
2222
retriever
2323
=========
@@ -33,13 +33,13 @@ Port 9009 - Open to 0.0.0.0/0
3333
3434
lvm
3535
===
36-
Port 9000 - Open to 0.0.0.0/0
36+
Port 9399 - Open to 0.0.0.0/0
3737
38-
chaqna-xeon-backend-server
38+
videoqna-xeon-backend-server
3939
==========================
4040
Port 8888 - Open to 0.0.0.0/0
4141
42-
chaqna-xeon-ui-server
42+
videoqna-xeon-ui-server
4343
=====================
4444
Port 5173 - Open to 0.0.0.0/0
4545
```
@@ -106,17 +106,14 @@ docker build -t opea/videoqna-ui:latest --build-arg https_proxy=$https_proxy --b
106106

107107
Then run the command `docker images`, you will have the following 8 Docker Images:
108108

109+
1. `opea/embedding-multimodal-clip:latest`
110+
1. `opea/retriever:latest`
111+
1. `opea/reranking:latest`
112+
1. `opea/lvm-video-llama:latest`
113+
1. `opea/lvm:latest`
109114
1. `opea/dataprep:latest`
110-
2. `opea/embedding-multimodal-clip:latest`
111-
3. `opea/retriever:latest`
112-
4. `opea/reranking:latest`
113-
5. `opea/video-llama-lvm-server:latest`
114-
6. # `opea/lvm-video-llama:latest`
115-
7. `opea/reranking-tei:latest`
116-
8. `opea/lvm-video-llama:latest`
117-
9. `opea/lvm:latest`
118-
10. `opea/videoqna:latest`
119-
11. `opea/videoqna-ui:latest`
115+
1. `opea/videoqna:latest`
116+
1. `opea/videoqna-ui:latest`
120117

121118
## 🚀 Start Microservices
122119

@@ -132,18 +129,18 @@ Since the `compose.yaml` will consume some environment variables, you need to se
132129
export host_ip="External_Public_IP"
133130
```
134131

135-
**Export the value of your Huggingface API token to the `your_hf_api_token` environment variable**
132+
**Export the value of your Huggingface API token to the `HF_TOKEN` environment variable**
136133

137134
> Change the `Your_Huggingface_API_Token` below with your actual Huggingface API Token value
138135
139136
```
140-
export your_hf_api_token="Your_Huggingface_API_Token"
137+
export HF_TOKEN="Your_Huggingface_API_Token"
141138
```
142139

143140
**Append the value of the public IP address to the no_proxy list**
144141

145142
```
146-
export your_no_proxy="${your_no_proxy},${host_ip}"
143+
export no_proxy="${your_no_proxy},${host_ip}"
147144
```
148145

149146
Then you can run below commands or `source set_env.sh` to set all the variables
@@ -152,26 +149,52 @@ Then you can run below commands or `source set_env.sh` to set all the variables
152149
export no_proxy=${your_no_proxy}
153150
export http_proxy=${your_http_proxy}
154151
export https_proxy=${your_http_proxy}
155-
export MEGA_SERVICE_HOST_IP=${host_ip}
156-
export EMBEDDING_SERVICE_HOST_IP=${host_ip}
157-
export RETRIEVER_SERVICE_HOST_IP=${host_ip}
158-
export RERANK_SERVICE_HOST_IP=${host_ip}
159-
export LVM_SERVICE_HOST_IP=${host_ip}
160152

161-
export LVM_ENDPOINT="http://${host_ip}:9009"
162-
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8888/v1/videoqna"
163-
export BACKEND_HEALTH_CHECK_ENDPOINT="http://${host_ip}:8888/v1/health_check"
164-
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6007/v1/dataprep/ingest"
165-
export DATAPREP_GET_FILE_ENDPOINT="http://${host_ip}:6007/v1/dataprep/get"
166-
export DATAPREP_GET_VIDEO_LIST_ENDPOINT="http://${host_ip}:6007/v1/dataprep/get_videos"
153+
export HF_TOKEN=${HF_TOKEN}
154+
export HUGGINGFACEHUB_API_TOKEN=${HF_TOKEN}
167155

168-
export VDMS_HOST=${host_ip}
169-
export VDMS_PORT=8001
170156
export INDEX_NAME="mega-videoqna"
171-
export LLM_DOWNLOAD="True"
157+
export LLM_DOWNLOAD="True" # Set to "False" before redeploy LVM server to avoid model download
158+
export RERANK_COMPONENT_NAME="OPEA_VIDEO_RERANKING"
159+
export LVM_COMPONENT_NAME="OPEA_VIDEO_LLAMA_LVM"
160+
export EMBEDDING_COMPONENT_NAME="OPEA_CLIP_EMBEDDING"
172161
export USECLIP=1
162+
export LOGFLAG=True
173163

174-
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
164+
export EMBEDDING_SERVICE_HOST_IP=${host_ip}
165+
export LVM_SERVICE_HOST_IP=${host_ip}
166+
export MEGA_SERVICE_HOST_IP=${host_ip}
167+
export RERANK_SERVICE_HOST_IP=${host_ip}
168+
export RETRIEVER_SERVICE_HOST_IP=${host_ip}
169+
export VDMS_HOST=${host_ip}
170+
171+
export BACKEND_PORT=8888
172+
export DATAPREP_PORT=6007
173+
export EMBEDDER_PORT=6990
174+
export MULTIMODAL_CLIP_EMBEDDER_PORT=6991
175+
export LVM_PORT=9399
176+
export RERANKING_PORT=8000
177+
export RETRIEVER_PORT=7000
178+
export UI_PORT=5173
179+
export VDMS_PORT=8001
180+
export VIDEO_LLAMA_PORT=9009
181+
182+
export BACKEND_HEALTH_CHECK_ENDPOINT="http://${host_ip}:${BACKEND_PORT}/v1/health_check"
183+
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:${BACKEND_PORT}/v1/videoqna"
184+
export CLIP_EMBEDDING_ENDPOINT="http://${host_ip}:${MULTIMODAL_CLIP_EMBEDDER_PORT}"
185+
export DATAPREP_GET_FILE_ENDPOINT="http://${host_ip}:${DATAPREP_PORT}/v1/dataprep/get"
186+
export DATAPREP_GET_VIDEO_LIST_ENDPOINT="http://${host_ip}:${DATAPREP_PORT}/v1/dataprep/get_videos"
187+
export DATAPREP_INGEST_SERVICE_ENDPOINT="http://${host_ip}:${DATAPREP_PORT}/v1/dataprep/ingest"
188+
export EMBEDDING_ENDPOINT="http://${host_ip}:${EMBEDDER_PORT}/v1/embeddings"
189+
export FRONTEND_ENDPOINT="http://${host_ip}:${UI_PORT}/_stcore/health"
190+
export LVM_ENDPOINT="http://${host_ip}:${VIDEO_LLAMA_PORT}"
191+
export LVM_VIDEO_ENDPOINT="http://${host_ip}:${VIDEO_LLAMA_PORT}/generate"
192+
export RERANKING_ENDPOINT="http://${host_ip}:${RERANKING_PORT}/v1/reranking"
193+
export RETRIEVER_ENDPOINT="http://${host_ip}:${RETRIEVER_PORT}/v1/retrieval"
194+
export TEI_RERANKING_ENDPOINT="http://${host_ip}:${TEI_RERANKING_PORT}"
195+
export UI_ENDPOINT="http://${host_ip}:${UI_PORT}/_stcore/health"
196+
197+
export no_proxy="${NO_PROXY},${host_ip},vdms-vector-db,dataprep-vdms-server,clip-embedding-server,reranking-tei-server,retriever-vdms-server,lvm-video-llama,lvm,videoqna-xeon-backend-server,videoqna-xeon-ui-server"
175198
```
176199

177200
Note: Replace with `host_ip` with you external IP address, do not use localhost.
@@ -190,12 +213,13 @@ In the deploy steps, you need to start the VDMS DB and dataprep firstly, then in
190213
```bash
191214
cd GenAIExamples/VideoQnA/docker_compose/intel/cpu/xeon/
192215

193-
docker volume create video-llama-model
216+
docker volume create video-llama-
217+
docker volume create videoqna-cache
194218
docker compose up vdms-vector-db dataprep -d
195-
sleep 1m # wait for the services ready
219+
sleep 30s
196220

197221
# Insert some sample data to the DB
198-
curl -X POST http://${host_ip}:6007/v1/dataprep/ingest \
222+
curl -X POST ${DATAPREP_INGEST_SERVICE_ENDPOINT} \
199223
-H "Content-Type: multipart/form-data" \
200224
-F "files=@./data/op_1_0320241830.mp4"
201225

@@ -212,11 +236,12 @@ docker compose up -d
212236

213237
```bash
214238
# Single file upload
215-
curl -X POST ${DATAPREP_SERVICE_ENDPOINT} \
239+
curl -X POST ${DATAPREP_INGEST_SERVICE_ENDPOINT} \
216240
-H "Content-Type: multipart/form-data" \
217241
-F "files=@./file1.mp4"
242+
218243
# Multiple file upload
219-
curl -X POST ${DATAPREP_SERVICE_ENDPOINT} \
244+
curl -X POST ${DATAPREP_INGEST_SERVICE_ENDPOINT} \
220245
-H "Content-Type: multipart/form-data" \
221246
-F "files=@./file1.mp4" \
222247
-F "files=@./file2.mp4" \
@@ -228,16 +253,17 @@ docker compose up -d
228253
```bash
229254
# List available videos
230255
curl -X 'GET' ${DATAPREP_GET_VIDEO_LIST_ENDPOINT} -H 'accept: application/json'
256+
231257
# Download available video
232258
curl -X 'GET' ${DATAPREP_GET_FILE_ENDPOINT}/video_name.mp4 -H 'accept: application/json'
233259
```
234260

235261
2. Embedding Microservice
236262

237263
```bash
238-
curl http://${host_ip}:6000/v1/embeddings \
264+
curl ${EMBEDDING_ENDPOINT} \
239265
-X POST \
240-
-d '{"text":"Sample text"}' \
266+
-d '{"input":"What is the man doing?"}' \
241267
-H 'Content-Type: application/json'
242268
```
243269

@@ -251,16 +277,16 @@ docker compose up -d
251277

252278
```bash
253279
export your_embedding=$(python3 -c "import random; embedding = [random.uniform(-1, 1) for _ in range(512)]; print(embedding)")
254-
curl http://${host_ip}:7000/v1/retrieval \
280+
curl ${RETRIEVER_ENDPOINT} \
255281
-X POST \
256-
-d "{\"text\":\"test\",\"embedding\":${your_embedding}}" \
282+
-d "{\"text\":\"What is the man doing?\",\"embedding\":${your_embedding},\"search_type\":\"mmr\", \"k\":4}" \
257283
-H 'Content-Type: application/json'
258284
```
259285

260286
4. Reranking Microservice
261287

262288
```bash
263-
curl http://${host_ip}:8000/v1/reranking \
289+
curl ${RERANKING_ENDPOINT} \
264290
-X 'POST' \
265291
-H 'accept: application/json' \
266292
-H 'Content-Type: application/json' \
@@ -282,7 +308,7 @@ docker compose up -d
282308

283309
```bash
284310
curl -X POST \
285-
"http://${host_ip}:9009/generate?video_url=silence_girl.mp4&start=0.0&duration=9&prompt=What%20is%20the%20person%20doing%3F&max_new_tokens=150" \
311+
"${LVM_VIDEO_ENDPOINT}?video_url=silence_girl.mp4&start=0.0&duration=9&prompt=What%20is%20the%20person%20doing%3F&max_new_tokens=150" \
286312
-H "accept: */*" \
287313
-d ''
288314
```
@@ -294,9 +320,9 @@ docker compose up -d
294320
This service depends on above LLM backend service startup. It will be ready after long time, to wait for them being ready in first startup.
295321

296322
```bash
297-
curl http://${host_ip}:9000/v1/lvm\
323+
curl http://${host_ip}:${LVM_PORT}/v1/lvm \
298324
-X POST \
299-
-d '{"video_url":"https://github.com/DAMO-NLP-SG/Video-LLaMA/raw/main/examples/silence_girl.mp4","chunk_start": 0,"chunk_duration": 7,"prompt":"What is the person doing?","max_new_tokens": 50}' \
325+
-d '{"video_url":"https://github.com/DAMO-NLP-SG/Video-LLaMA/raw/main/examples/silence_girl.mp4","chunk_start": 0,"chunk_duration": 7,"prompt":"What is the man doing?","max_new_tokens": 50}' \
300326
-H 'Content-Type: application/json'
301327
```
302328

@@ -305,7 +331,7 @@ docker compose up -d
305331
7. MegaService
306332

307333
```bash
308-
curl http://${host_ip}:8888/v1/videoqna -H "Content-Type: application/json" -d '{
334+
curl ${BACKEND_SERVICE_ENDPOINT} -H "Content-Type: application/json" -d '{
309335
"messages": "What is the man doing?",
310336
"stream": "True"
311337
}'
@@ -343,4 +369,5 @@ To clean the volume:
343369

344370
```bash
345371
docker volume rm video-llama-model
372+
docker volume rm videoqna-cache
346373
```

0 commit comments

Comments
 (0)