Compare commits

...

8 Commits

Author SHA1 Message Date
12eb7f5009 更新 .gitea/workflows/prod_build_manual.yaml 2026-02-09 15:32:47 +08:00
a249d53d98 更新 docker-compose.yml 2026-02-09 15:30:06 +08:00
7c79bb161b 更新 .gitea/workflows/prod_build_manual.yaml 2026-02-09 15:07:11 +08:00
zcr
cd0b6116e9 更新 docker 配置,替换pip为uv 加速构建 2025-12-23 15:23:24 +08:00
zcr
aa1b087090 更新 docker 配置,替换pip为uv 加速构建 2025-12-23 15:18:36 +08:00
zcr
9fbfe9c674 端口恢复 2025-12-23 11:06:56 +08:00
zcr
811b3c1160 新增生产部署 actions 2025-12-23 10:53:36 +08:00
zcr
a77362a50a 通道校验 保持三通道 2025-12-23 10:51:20 +08:00
6 changed files with 3307 additions and 33 deletions

View File

@@ -0,0 +1,40 @@
name: 手动 LC python main 分支构建部署
on:
workflow_dispatch:
jobs:
scheduled_deploy:
runs-on: ubuntu-latest
env:
REMOTE_DEPLOY_PATH: /workspace/LC_Workspace/LitServe_Server_Workspace/LC_NeoRefacer
steps:
- name: 1.检出代码
uses: actions/checkout@v4
with:
ref: 'main'
- name: 2.复制文件到服务器
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
source: "."
target: ${{ env.REMOTE_DEPLOY_PATH }}
- name: 3.重启docker-compose
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
# 进入项目目录
cd ${{ env.REMOTE_DEPLOY_PATH }}
docker-compose down 2>&1
docker-compose up -d 2>&1
docker image prune -f 2>&1

View File

@@ -1,40 +1,37 @@
# Change CUDA and cuDNN version here
FROM ghcr.io/astral-sh/uv:latest AS uv_bin
FROM nvidia/cuda:12.4.1-base-ubuntu22.04
ARG PYTHON_VERSION=3.11
ENV DEBIAN_FRONTEND=noninteractive
# 1. 基础环境配置
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
PYTHONUNBUFFERED=1 \
# 核心:强制 uv 把虚拟环境建在 /app/.venv
UV_PROJECT_ENVIRONMENT=/app/.venv
COPY --from=uv_bin /uv /uvx /bin/
# 2. 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
wget \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y --no-install-recommends \
python$PYTHON_VERSION \
python$PYTHON_VERSION-dev \
python$PYTHON_VERSION-venv \
&& wget https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
&& python$PYTHON_VERSION get-pip.py \
&& rm get-pip.py \
&& ln -sf /usr/bin/python$PYTHON_VERSION /usr/bin/python \
&& ln -sf /usr/local/bin/pip$PYTHON_VERSION /usr/local/bin/pip \
&& python --version \
&& pip --version \
&& apt-get purge -y --auto-remove software-properties-common \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
####### Add your own installation commands here #######
# RUN pip install some-package
# RUN wget https://path/to/some/data/or/weights
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y \
&& apt install -y build-essential g++
ffmpeg libsm6 libxext6 build-essential g++ \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . /app
# Install litserve and requirements
RUN pip install --no-cache-dir litserve==0.2.16
RUN pip install -r requirements-GPU.txt
RUN pip install opencv-python
# 3. 安装依赖 (不加 --system让 uv 创建受管的虚拟环境)
# 这里会根据 pyproject.toml 自动下载并安装 Python 3.11
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project --python 3.11
# 4. 拷贝项目文件并安装项目本身
COPY . .
RUN uv sync --frozen --no-dev --python 3.11
# 5. 【最关键】将虚拟环境的 bin 目录提到最前面
# 注意uv sync 创建的 python 就在这个目录下
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
CMD ["python", "litserver_main.py"]
#CMD ["tail", "-f","/dev/null"]
# 验证路径并运行
# 此时运行 python 实际上是运行 /app/.venv/bin/python
CMD ["uv", "run","litserver_main.py"]

View File

@@ -1,5 +1,6 @@
services:
lc_neo_refacer:
container_name: LC_Refacer_Server
build:
context: .
dockerfile: Dockerfile

View File

@@ -29,6 +29,8 @@ class InferencePipeline(ls.LitAPI):
'img_path': path
})
dest_img = oss_get_image(oss_client=minio_client, path=request.input_face, data_type="cv2")
if dest_img.shape[2] == 4:
dest_img = cv2.cvtColor(dest_img, cv2.COLOR_RGBA2RGB)
faces_config = [
{
'origin': None,

26
pyproject.toml Normal file
View File

@@ -0,0 +1,26 @@
[project]
name = "lc-neorefacer"
version = "0.1.0"
description = "Add your description here"
requires-python = ">=3.11"
dependencies = [
"ffmpeg-python>=0.2.0",
"gdown>=5.2.0",
"gradio>=6.2.0",
"imageio[ffmpeg]>=2.37.2",
"insightface>=0.7.3",
"litserve>=0.2.16",
"lpips>=0.1.4",
"minio>=7.2.20",
"ngrok>=1.4.0",
"onnx>=1.20.0",
"onnxruntime>=1.23.2",
"opencv-contrib-python>=4.12.0.88",
"pillow>=12.0.0",
"pyfiglet>=1.0.4",
"requests>=2.32.5",
"scikit-image>=0.26.0",
"torch>=2.9.1",
"torchvision>=0.24.1",
"tqdm>=4.67.1",
]

3208
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff