chore: setup replicate deployment

This commit is contained in:
mbukeRepo 2024-07-06 13:13:39 +02:00
parent d09527c762
commit bd9401a696
3 changed files with 73 additions and 0 deletions

17
.dockerignore Normal file
View File

@ -0,0 +1,17 @@
# The .dockerignore file excludes files from the container build process.
#
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Exclude Git files
.git
.github
.gitignore
# Exclude Python cache files
__pycache__
.mypy_cache
.pytest_cache
.ruff_cache
# Exclude Python virtual environment
/venv

27
cog.yaml Normal file
View File

@ -0,0 +1,27 @@
# Configuration for Cog ⚙️
# Reference: https://cog.run/yaml
build:
gpu: true
python_version: "3.11"
python_packages:
- "torch==2.3.0"
- "torchvision==0.18.0"
- "torchaudio==2.3.0"
- "numpy==1.26.4"
- "pyyaml==6.0.1"
- "opencv-python==4.10.0.84"
- "scipy==1.13.1"
- "imageio==2.34.2"
- "lmdb==1.4.1"
- "tqdm==4.66.4"
- "rich==13.7.1"
- "ffmpeg==1.4"
- "onnxruntime-gpu==1.18.0"
- "onnx==1.16.1"
- "scikit-image==0.24.0"
- "albumentations==1.4.10"
- "matplotlib==3.9.0"
- "imageio-ffmpeg==0.5.1"
- "tyro==0.8.5"
predict: "predict.py:Predictor"

29
predict.py Normal file
View File

@ -0,0 +1,29 @@
from cog import BasePredictor, Input, Path
from src.config.argument_config import ArgumentConfig
from src.config.inference_config import InferenceConfig
from src.config.crop_config import CropConfig
from src.live_portrait_pipeline import LivePortraitPipeline
class Predictor(BasePredictor):
def setup(self) -> None:
"""Load the model into memory to make running multiple predictions efficient"""
self.live_portrait_pipeline = LivePortraitPipeline(
inference_cfg=InferenceConfig(),
crop_cfg=CropConfig()
)
def predict(
self,
image: Path = Input(description="Portrait image"),
driving_info: Path = Input(
description="driving video or template (.pkl format)"
),
) -> Path:
"""Run a single prediction on the model"""
video_path, _ = self.live_portrait_pipeline.execute(
ArgumentConfig(source_image=image, driving_info=driving_info, output_dir="/tmp/")
)
return Path(video_path)