Skip to content

Commit

Permalink
Add Noop pipeline for local testing (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko authored Nov 18, 2024
1 parent d75e3e0 commit e4aac00
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 1 deletion.
3 changes: 3 additions & 0 deletions runner/app/live/pipelines/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ def load_pipeline(name: str, **params) -> Pipeline:
elif name == "comfyui":
from .comfyui import ComfyUI
return ComfyUI(**params)
elif name == "noop":
from .noop import Noop
return Noop(**params)
raise ValueError(f"Unknown pipeline: {name}")
14 changes: 14 additions & 0 deletions runner/app/live/pipelines/noop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from PIL import Image
import logging

from .interface import Pipeline

class Noop(Pipeline):
def __init__(self, **params):
super().__init__(**params)

def process_frame(self, image: Image.Image) -> Image.Image:
return image.convert("RGB")

def update_params(self, **params):
logging.info(f"Updating params: {params}")
3 changes: 2 additions & 1 deletion runner/app/pipelines/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import numpy as np
import torch
from diffusers.pipelines.pipeline_utils import DiffusionPipeline
from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
from PIL import Image
from torch import dtype as TorchDtype
from transformers import CLIPImageProcessor
Expand Down Expand Up @@ -154,6 +153,8 @@ def __init__(

self.device = device
self._dtype = dtype

from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
self._safety_checker = StableDiffusionSafetyChecker.from_pretrained(
"CompVis/stable-diffusion-safety-checker"
).to(self.device)
Expand Down
36 changes: 36 additions & 0 deletions runner/docker/Dockerfile.live-app-noop
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG BASE_IMAGE=livepeer/ai-runner:live-base
FROM ${BASE_IMAGE}

# Install latest stable Go version and system dependencies
RUN apt-get update && apt-get install -y \
wget \
libcairo2-dev \
libgirepository1.0-dev \
pkg-config \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

ARG PYTHON_VERSION=3.10
RUN pyenv install $PYTHON_VERSION && \
pyenv global $PYTHON_VERSION && \
pyenv rehash

# Upgrade pip and install required packages
ARG PIP_VERSION=23.3.2

# Install any additional Python packages
RUN pip install uvicorn==0.30.0 fastapi==0.111.0 numpy==1.26.4 torch==2.5.1 diffusers==0.30.0 transformers==4.43.3 aiohttp==3.10.9 pyzmq==26.2.0

# Set environment variables
ENV MAX_WORKERS=1
ENV HUGGINGFACE_HUB_CACHE=/models
ENV DIFFUSERS_CACHE=/models
ENV MODEL_DIR=/models

# Copy application files
COPY app/ /app/app
COPY images/ /app/images
COPY bench.py /app/bench.py

WORKDIR /app

CMD ["uvicorn", "app.main:app", "--log-config", "app/cfg/uvicorn_logging_config.json", "--host", "0.0.0.0", "--port", "8000"]
15 changes: 15 additions & 0 deletions runner/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ To build a pipeline-specific container, you need to build the base container fir
1. Build Docker image
```
export PIPELINE=comfyui
docker build -t livepeer/ai-runner:live-base -f docker/Dockerfile.live-base .
docker build -t livepeer/ai-runner:live-base-${PIPELINE} -f docker/Dockerfile.live-base-${PIPELINE} .
docker build -t livepeer/ai-runner:live-app-${PIPELINE} -f docker/Dockerfile.live-app__PIPELINE__ --build-arg PIPELINE=${PIPELINE} .
```
Expand All @@ -61,4 +62,18 @@ mv ./models/*.engine ./models/tensorrt/depth-anything
```
docker run -it --rm --name video-to-video --gpus all -p 8000:8000 -v ./models:/models -e PIPELINE=live-video-to-video -e MODEL_ID=comfyui livepeer/ai-runner:live-app-comfyui
```
### Noop pipeline for local testing (works on Darwin as well)
1. Build Docker images
```
export PIPELINE=noop
docker build -t livepeer/ai-runner:live-base -f docker/Dockerfile.live-base .
docker build -t livepeer/ai-runner:live-app-${PIPELINE} -f docker/Dockerfile.live-app-noop .
```
2. Start Docker container
```
docker run -it --rm --name video-to-video -p 8000:8000 -e PIPELINE=live-video-to-video -e MODEL_ID=noop livepeer/ai-runner:live-app-noop
```

0 comments on commit e4aac00

Please sign in to comment.