Skip to content

Commit

Permalink
Rename folder name integration to integrations in image2image and ani…
Browse files Browse the repository at this point in the history
…mation (#1130)

Signed-off-by: Yao, Qing <qing.yao@intel.com>
Co-authored-by: ZePan110 <ze.pan@intel.com>
  • Loading branch information
yao531441 and ZePan110 authored Jan 10, 2025
1 parent e7b8d25 commit 4f9f955
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 33 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/docker/compose/3rd_parties-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ services:
build:
dockerfile: comps/3rd_parties/nginx/src/Dockerfile
image: ${REGISTRY:-opea}/nginx:${TAG:-latest}

wav2lip:
build:
dockerfile: comps/3rd_parties/wav2lip/src/Dockerfile
image: ${REGISTRY:-opea}/wav2lip:${TAG:-latest}
wav2lip-gaudi:
build:
dockerfile: comps/3rd_parties/wav2lip/src/Dockerfile.intel_hpu
image: ${REGISTRY:-opea}/wav2lip-gaudi:${TAG:-latest}
4 changes: 2 additions & 2 deletions .github/workflows/docker/compose/animation-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ services:
image: ${REGISTRY:-opea}/animation:${TAG:-latest}
wav2lip:
build:
dockerfile: comps/animation/src/integration/dependency/Dockerfile
dockerfile: comps/3rd_parties/wav2lip/src/Dockerfile
image: ${REGISTRY:-opea}/wav2lip:${TAG:-latest}
wav2lip-gaudi:
build:
dockerfile: comps/animation/src/integration/dependency/Dockerfile.intel_hpu
dockerfile: comps/3rd_parties/wav2lip/src/Dockerfile.intel_hpu
image: ${REGISTRY:-opea}/wav2lip-gaudi:${TAG:-latest}
2 changes: 1 addition & 1 deletion .github/workflows/scripts/get_test_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function find_test_1() {
changed_integrations=$(printf '%s\n' "${changed_files[@]}"| grep ${service_path} | grep -E 'integrations' | cut -d'/' -f$((n+2)) | cut -d'.' -f1 | sort -u) || true
for integration in ${changed_integrations}; do
# Accurate matching test scripts
# find_test=$(find ./tests -type f \( -name test_${service_name}_${integration}.sh -o -name test_${service_name}_${integration}_on_*.sh \)) || true
# find_test=$(find ./tests -type f \( -name test_${service_name}_${integrations}.sh -o -name test_${service_name}_${integrations}_on_*.sh \)) || true
# Fuzzy matching test scripts, for example, llms/src/text-generation/integrations/opea.py match several tests.
find_test=$(find ./tests -type f -name test_${service_name}_${integration}*.sh) || true
if [ "$find_test" ]; then
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missin
# Install GenAIComps
RUN mkdir -p /home/user/comps
COPY comps /home/user/comps
COPY comps/animation/src/integration/dependency/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY comps/3rd_parties/wav2lip/src/entrypoint.sh /usr/local/bin/entrypoint.sh

# Install ffmpeg with x264 software codec
RUN git clone https://github.com/FFmpeg/FFmpeg.git /home/user/comps/animation/src/FFmpeg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN rm -rf /var/lib/apt/lists/*
# Install GenAIComps
RUN mkdir -p /home/user/comps
COPY comps /home/user/comps
COPY comps/animation/src/integration/dependency/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY comps/3rd_parties/wav2lip/src/entrypoint.sh /usr/local/bin/entrypoint.sh

# Install ffmpeg with x264 software codec
RUN git clone https://github.com/FFmpeg/FFmpeg.git /home/user/comps/animation/FFmpeg
Expand Down
2 changes: 2 additions & 0 deletions comps/3rd_parties/wav2lip/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export PT_HPU_LAZY_MODE=0
export PT_HPU_ENABLE_REFINE_DYNAMIC_SHAPES=1

# Wav2Lip, GFPGAN
cd /home/user/comps/animation/src/integration/ || exit
python3 dependency/wav2lip_server.py \
cd /home/user/comps/3rd_parties/wav2lip/src || exit
python3 wav2lip_server.py \
--device $DEVICE \
--port $((WAV2LIP_PORT)) \
--inference_mode $INFERENCE_MODE \
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions comps/animation/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ cd GenAIComps
- Xeon CPU

```bash
docker build -t opea/wav2lip:latest -f comps/animation/src/integration/dependency/Dockerfile .
docker build -t opea/wav2lip:latest -f comps/3rd_parties/wav2lip/src/Dockerfile .
```

- Gaudi2 HPU

```bash
docker build -t opea/wav2lip-gaudi:latest -f comps/animation/src/integration/dependency/Dockerfile.intel_hpu .
docker build -t opea/wav2lip-gaudi:latest -f comps/3rd_parties/wav2lip/src/Dockerfile.intel_hpu .
```

### 1.1.2 Animation server image
Expand Down Expand Up @@ -101,7 +101,7 @@ Once microservice starts, user can use below script to validate the running micr

```bash
cd GenAIComps
python3 comps/animation/src/integration/dependency/check_wav2lip_server.py
python3 comps/3rd_parties/wav2lip/src/check_wav2lip_server.py
```

## 3.2 Validate Animation service
Expand All @@ -116,7 +116,7 @@ or

```bash
cd GenAIComps
python3 comps/animation/src/integration/dependency/check_animation_server.py
python3 comps/3rd_parties/wav2lip/src/check_animation_server.py
```

The expected output will be a message similar to the following:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, name: str, description: str, config: dict = None):
if not health_status:
logger.error("OpeaAnimation health check failed.")

def invoke(self, input: str):
async def invoke(self, input: str):
"""Invokes the animation service to generate embeddings for the animation input.
Args:
Expand Down
6 changes: 3 additions & 3 deletions comps/animation/src/opea_animation_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# GenAIComps
from comps import CustomLogger, OpeaComponentLoader
from comps.animation.src.integration.opea import OpeaAnimation
from comps.animation.src.integrations.wav2lip import OpeaAnimation

logger = CustomLogger("opea_animation")
logflag = os.getenv("LOGFLAG", False)
Expand Down Expand Up @@ -43,10 +43,10 @@
output_datatype=VideoPath,
)
@register_statistics(names=["opea_service@animation"])
def animate(audio: Base64ByteStrDoc):
async def animate(audio: Base64ByteStrDoc):
start = time.time()

outfile = loader.invoke(audio.byte_str)
outfile = await loader.invoke(audio.byte_str)
if logflag:
logger.info(f"Video generated successfully, check {outfile} for the result.")

Expand Down
4 changes: 2 additions & 2 deletions comps/cores/proto/api_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ class FineTuningJobWandbIntegration(BaseModel):

class FineTuningJobWandbIntegrationObject(BaseModel):
type: Literal["wandb"]
"""The type of the integration being enabled for the fine-tuning job."""
"""The type of the integrations being enabled for the fine-tuning job."""

wandb: FineTuningJobWandbIntegration
"""The settings for your integration with Weights and Biases.
"""The settings for your integrations with Weights and Biases.
This payload specifies the project that metrics will be sent to. Optionally, you
can set an explicit display name for your run, add tags to your run, and set a
Expand Down
2 changes: 0 additions & 2 deletions comps/image2image/src/integration/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
import base64
import os
import tempfile
import threading

from comps import CustomLogger, OpeaComponent, OpeaComponentRegistry, SDImg2ImgInputs, ServiceType
Expand Down Expand Up @@ -99,7 +100,7 @@ def __init__(
if not health_status:
logger.error("OpeaImageToImage health check failed.")

def invoke(self, input: SDImg2ImgInputs):
async def invoke(self, input: SDImg2ImgInputs):
"""Invokes the ImageToImage service to generate Images for the provided input.
Args:
Expand All @@ -113,16 +114,15 @@ def invoke(self, input: SDImg2ImgInputs):
images = pipe(
image=image, prompt=prompt, generator=generator, num_images_per_prompt=num_images_per_prompt
).images
image_path = os.path.join(os.getcwd(), prompt.strip().replace(" ", "_").replace("/", ""))
os.makedirs(image_path, exist_ok=True)
results = []
for i, image in enumerate(images):
save_path = os.path.join(image_path, f"image_{i + 1}.png")
image.save(save_path)
with open(save_path, "rb") as f:
bytes = f.read()
b64_str = base64.b64encode(bytes).decode()
results.append(b64_str)
with tempfile.TemporaryDirectory() as image_path:
for i, image in enumerate(images):
save_path = os.path.join(image_path, f"image_{i + 1}.png")
image.save(save_path)
with open(save_path, "rb") as f:
bytes = f.read()
b64_str = base64.b64encode(bytes).decode()
results.append(b64_str)

return results

Expand Down
6 changes: 3 additions & 3 deletions comps/image2image/src/opea_image2image_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
register_statistics,
statistics_dict,
)
from comps.image2image.src.integration.opea_image2image_native import OpeaImageToImage
from comps.image2image.src.integrations.native import OpeaImageToImage

args = None

Expand All @@ -36,9 +36,9 @@
output_datatype=SDOutputs,
)
@register_statistics(names=["opea_service@image2image"])
def image2image(input: SDImg2ImgInputs):
async def image2image(input: SDImg2ImgInputs):
start = time.time()
results = component_loader.invoke(input)
results = await component_loader.invoke(input)
statistics_dict["opea_service@image2image"].append_latency(time.time() - start, None)
return SDOutputs(images=results)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ip_address=$(hostname -I | awk '{print $1}')
function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build -t opea/wav2lip:comps -f comps/animation/src/integration/dependency/Dockerfile .
docker build -t opea/wav2lip:comps -f comps/3rd_parties/wav2lip/src/Dockerfile .
if [ $? -ne 0 ]; then
echo "opea/wav2lip built fail"
exit 1
Expand Down

0 comments on commit 4f9f955

Please sign in to comment.