Skip to content
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

Refactor lvms #1096

Merged
merged 45 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1cad5c6
draft lvm refactor
Spycsh Dec 20, 2024
23ddd8c
add microservice wrapepr
Spycsh Dec 20, 2024
5015d88
add integrations
Spycsh Dec 23, 2024
c12bbf5
refactor
Spycsh Dec 23, 2024
b281685
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 23, 2024
d098994
Merge remote-tracking branch 'source/main' into refactor_lvm
Spycsh Dec 30, 2024
863c032
add wrapper dockerfile, revert healthcheck
Spycsh Dec 30, 2024
9aa425b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2024
e678ccc
paths
Spycsh Dec 30, 2024
7679586
Merge branch 'refactor_lvm' of https://github.com/Spycsh/GenAIComps i…
Spycsh Dec 30, 2024
0117ce4
fix tests
Spycsh Dec 30, 2024
09f5960
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 30, 2024
df77b1d
distinguish between controller/integrations with register
Spycsh Dec 30, 2024
fbedabe
Merge branch 'refactor_lvm' of https://github.com/Spycsh/GenAIComps i…
Spycsh Dec 30, 2024
2f49433
debug
Spycsh Dec 31, 2024
32db6fc
fix
Spycsh Dec 31, 2024
517d3f1
handle streamingresponse for video llama
Spycsh Dec 31, 2024
2bb5ac9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 31, 2024
5d44050
fix test
Spycsh Dec 31, 2024
d6c0889
Merge branch 'refactor_lvm' of https://github.com/Spycsh/GenAIComps i…
Spycsh Dec 31, 2024
4168bca
fix
Spycsh Dec 31, 2024
6d6f216
Update test_dataprep_multimodal_redis_langchain.sh
Spycsh Dec 31, 2024
8b8800a
Merge remote-tracking branch 'source/main' into refactor_lvm
Spycsh Jan 2, 2025
9750860
Merge branch 'refactor_lvm' of https://github.com/Spycsh/GenAIComps i…
Spycsh Jan 2, 2025
5394a45
refactor names
Spycsh Jan 3, 2025
249a97d
Merge remote-tracking branch 'source/main' into source/refactor_lvm
Spycsh Jan 3, 2025
771b3f1
fix link
Spycsh Jan 3, 2025
11ca1eb
refactor links
Spycsh Jan 3, 2025
cdd6505
wrapper unify names
Spycsh Jan 3, 2025
c934b9f
Merge branch 'main' into source/refactor_lvm
Spycsh Jan 3, 2025
7fdc464
fix
Spycsh Jan 3, 2025
de9a1ba
Merge branch 'source/refactor_lvm' of https://github.com/opea-project…
Spycsh Jan 3, 2025
d0ddebe
fix
Spycsh Jan 7, 2025
9fb8608
remove
Spycsh Jan 7, 2025
fc0c945
use loader to make refactor happy
Spycsh Jan 7, 2025
5a05be1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 7, 2025
df4646a
healthcheck in init
Spycsh Jan 8, 2025
5b9021d
Merge remote-tracking branch 'source/main' into source/refactor_lvm
Spycsh Jan 8, 2025
2c32a4f
expose component name
Spycsh Jan 8, 2025
5045252
Merge branch 'main' into source/refactor_lvm
Spycsh Jan 8, 2025
836109b
all -> LVM_ENDPOINT
Spycsh Jan 8, 2025
259d928
Merge branch 'main' into source/refactor_lvm
Spycsh Jan 9, 2025
ef95553
Merge branch 'main' into source/refactor_lvm
ZePan110 Jan 10, 2025
a663bd5
fix conflict
Spycsh Jan 13, 2025
0798e2e
pin tf version
Spycsh Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions .github/workflows/docker/compose/lvms-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,40 @@
# SPDX-License-Identifier: Apache-2.0

# this file should be run in the root of the repo
# Deprecated original wrappers opea/lvm-tgi, opea/lvm-llava-svc, opea/lvm-video-llama
# and merged functionalities in opea/lvm
# Original video-llama-lvm-server renamed as lvm-video-llama

services:
lvm-tgi:
lvm:
build:
dockerfile: comps/lvms/tgi-llava/Dockerfile
image: ${REGISTRY:-opea}/lvm-tgi:${TAG:-latest}
dockerfile: comps/lvms/src/Dockerfile
image: ${REGISTRY:-opea}/lvm:${TAG:-latest}
lvm-video-llama:
build:
dockerfile: comps/lvms/video-llama/Dockerfile
dockerfile: comps/lvms/src/integrations/dependency/video-llama/Dockerfile
image: ${REGISTRY:-opea}/lvm-video-llama:${TAG:-latest}
video-llama-lvm-server:
build:
dockerfile: comps/lvms/video-llama/dependency/Dockerfile
image: ${REGISTRY:-opea}/video-llama-lvm-server:${TAG:-latest}
lvm-llava:
build:
dockerfile: comps/lvms/llava/dependency/Dockerfile
dockerfile: comps/lvms/src/integrations/dependency/llava/Dockerfile
image: ${REGISTRY:-opea}/lvm-llava:${TAG:-latest}
lvm-llava-svc:
build:
dockerfile: comps/lvms/llava/Dockerfile
image: ${REGISTRY:-opea}/lvm-llava-svc:${TAG:-latest}
llava-gaudi:
build:
dockerfile: comps/lvms/llava/dependency/Dockerfile.intel_hpu
dockerfile: comps/lvms/src/integrations/dependency/llava/Dockerfile.intel_hpu
image: ${REGISTRY:-opea}/llava-gaudi:${TAG:-latest}
lvm-predictionguard:
build:
dockerfile: comps/lvms/predictionguard/Dockerfile
dockerfile: comps/lvms/src/integrations/dependency/predictionguard/Dockerfile
image: ${REGISTRY:-opea}/lvm-predictionguard:${TAG:-latest}
lvm-llama-vision:
build:
dockerfile: comps/lvms/llama-vision/Dockerfile
dockerfile: comps/lvms/src/integrations/dependency/llama-vision/Dockerfile
image: ${REGISTRY:-opea}/lvm-llama-vision:${TAG:-latest}
lvm-llama-vision-tp:
build:
dockerfile: comps/lvms/llama-vision/Dockerfile_tp
dockerfile: comps/lvms/src/integrations/dependency/llama-vision/Dockerfile_tp
image: ${REGISTRY:-opea}/lvm-llama-vision-tp:${TAG:-latest}
lvm-llama-vision-guard:
build:
dockerfile: comps/lvms/llama-vision/Dockerfile_guard
dockerfile: comps/lvms/src/integrations/dependency/llama-vision/Dockerfile_guard
image: ${REGISTRY:-opea}/lvm-llama-vision-guard:${TAG:-latest}
6 changes: 6 additions & 0 deletions comps/cores/mega/http_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Optional

from fastapi import FastAPI
from fastapi.responses import Response
from prometheus_fastapi_instrumentator import Instrumentator
from uvicorn import Config, Server

Expand Down Expand Up @@ -73,6 +74,11 @@
"""Get the health status of this GenAI microservice."""
return {"Service Title": self.title, "Service Description": self.description}

@app.get("/health")
async def _health() -> Response:
"""Health check."""
return Response(status_code=200)

Check warning on line 80 in comps/cores/mega/http_service.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/mega/http_service.py#L80

Added line #L80 was not covered by tests

@app.get(
path="/v1/statistics",
summary="Get the statistics of GenAI services",
Expand Down
2 changes: 1 addition & 1 deletion comps/dataprep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apt-get install libreoffice

## Use LVM (Large Vision Model) for Summarizing Image Data

Occasionally unstructured data will contain image data, to convert the image data to the text data, LVM can be used to summarize the image. To leverage LVM, please refer to this [readme](../lvms/llava/README.md) to start the LVM microservice first and then set the below environment variable, before starting any dataprep microservice.
Occasionally unstructured data will contain image data, to convert the image data to the text data, LVM can be used to summarize the image. To leverage LVM, please refer to this [readme](../lvms/src/README.md) to start the LVM microservice first and then set the below environment variable, before starting any dataprep microservice.

```bash
export SUMMARIZE_IMAGE_VIA_LVM=1
Expand Down
4 changes: 2 additions & 2 deletions comps/dataprep/multimodal/redis/langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export PYTHONPATH=${path_to_comps}

This is required only if you are going to consume the _generate_captions_ API of this microservice as in [Section 4.3](#43-consume-generate_captions-api).

Please refer to this [readme](../../../../lvms/llava/README.md) to start the LVM microservice.
Please refer to this [readme](../../../../lvms/src/README.md) to start the LVM microservice.
After LVM is up, set up environment variables.

```bash
Expand All @@ -64,7 +64,7 @@ Please refer to this [readme](../../../../vectorstores/redis/README.md).

This is required only if you are going to consume the _generate_captions_ API of this microservice as described [here](#43-consume-generate_captions-api).

Please refer to this [readme](../../../../lvms/llava/README.md) to start the LVM microservice.
Please refer to this [readme](../../../../lvms/src/README.md) to start the LVM microservice.
After LVM is up, set up environment variables.

```bash
Expand Down
2 changes: 1 addition & 1 deletion comps/dataprep/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apt-get install libreoffice

## Use LVM (Large Vision Model) for Summarizing Image Data

Occasionally unstructured data will contain image data, to convert the image data to the text data, LVM can be used to summarize the image. To leverage LVM, please refer to this [readme](../../lvms/llava/README.md) to start the LVM microservice first and then set the below environment variable, before starting any dataprep microservice.
Occasionally unstructured data will contain image data, to convert the image data to the text data, LVM can be used to summarize the image. To leverage LVM, please refer to this [readme](../../lvms/src/README.md) to start the LVM microservice first and then set the below environment variable, before starting any dataprep microservice.

```bash
export SUMMARIZE_IMAGE_VIA_LVM=1
Expand Down
29 changes: 0 additions & 29 deletions comps/lvms/llava/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions comps/lvms/llava/__init__.py

This file was deleted.

22 changes: 0 additions & 22 deletions comps/lvms/llava/check_lvm.py

This file was deleted.

103 changes: 0 additions & 103 deletions comps/lvms/llava/lvm.py

This file was deleted.

17 changes: 0 additions & 17 deletions comps/lvms/llava/template.py

This file was deleted.

23 changes: 23 additions & 0 deletions comps/lvms/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

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

COPY comps /home/user/comps

RUN pip install --no-cache-dir --upgrade pip setuptools && \
pip install --no-cache-dir -r /home/user/comps/lvms/src/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/user/comps/lvms/src

ENTRYPOINT ["python", "opea_lvm_microservice.py"]
31 changes: 31 additions & 0 deletions comps/lvms/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# LVM Microservice

Visual Question and Answering is one of the multimodal tasks empowered by LVMs (Large Visual Models). This microservice supports visual Q&A by using LLaVA as the base large visual model. It accepts two inputs: a prompt and an image. It outputs the answer to the prompt about the image.

## Build Image & Run

Before this, you have to start the [dependency](./integrations/dependency/) service based on your demands.

```bash
docker build --no-cache -t opea/lvm:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/lvms/src/Dockerfile .
# Change LVM_ENDPOINT to you dependency service endpoint
docker run -d --name="test-comps-lvm" -e LVM_ENDPOINT=http://localhost:8399 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 9399:9399 --ipc=host opea/lvm:comps
```

## Test

- LLaVA & llama-vision & PredictionGuard & TGI LLaVA

```bash
# curl with an image and a prompt
http_proxy="" curl http://localhost:9399/v1/lvm -XPOST -d '{"image": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mP8/5+hnoEIwDiqkL4KAcT9GO0U4BxoAAAAAElFTkSuQmCC", "prompt":"What is this?"}' -H 'Content-Type: application/json'

# curl with only the prompt
http_proxy="" curl http://localhost:9399/v1/lvm --silent --write-out "HTTPSTATUS:%{http_code}" -XPOST -d '{"image": "", "prompt":"What is deep learning?"}' -H 'Content-Type: application/json'
```

- video-llama

```bash
http_proxy="" curl -X POST http://localhost:9399/v1/lvm -d '{"video_url":"https://github.com/DAMO-NLP-SG/Video-LLaMA/raw/main/examples/silence_girl.mp4","chunk_start": 0,"chunk_duration": 9,"prompt":"What is the person doing?","max_new_tokens": 150}' -H 'Content-Type: application/json'
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ RUN git lfs install

COPY comps /home/user/comps

RUN cd /home/user/comps/lvms/llama-vision/ && \
RUN cd /home/user/comps/lvms/src/integrations/dependency/llama-vision/ && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir --upgrade Pillow

ENV PYTHONPATH=/root:/home/user

WORKDIR /home/user/comps/lvms/llama-vision/
WORKDIR /home/user/comps/lvms/src/integrations/dependency/llama-vision/

ENTRYPOINT ["python", "lvm.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ RUN git lfs install

COPY comps /home/user/comps

RUN cd /home/user/comps/lvms/llama-vision/ && \
RUN cd /home/user/comps/lvms/src/integrations/dependency/llama-vision/ && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir --upgrade Pillow

ENV PYTHONPATH=/root:/home/user

WORKDIR /home/user/comps/lvms/llama-vision/
WORKDIR /home/user/comps/lvms/src/integrations/dependency/llama-vision/

ENTRYPOINT ["python", "lvm_guard.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ COPY comps /home/user/comps
RUN pip install --no-cache-dir git+https://github.com/HabanaAI/[email protected]
RUN pip install --no-cache-dir git+https://github.com/huggingface/[email protected]

RUN cd /home/user/comps/lvms/llama-vision/ \
RUN cd /home/user/comps/lvms/src/integrations/dependency/llama-vision/ \
pip install --no-cache-dir --upgrade pip && \
bash update && \
pip install --no-cache-dir -r /home/user/comps/lvms/llama-vision/requirements_tp.txt
pip install --no-cache-dir -r /home/user/comps/lvms/src/integrations/dependency/llama-vision/requirements_tp.txt

ENV PYTHONPATH=/root:/home/user

WORKDIR /home/user/comps/lvms/llama-vision/
WORKDIR /home/user/comps/lvms/src/integrations/dependency/llama-vision/

ENTRYPOINT ["bash", "run_tp.sh"]
Loading
Loading