Skip to content

Update deploy#568

Merged
helloyongyang merged 2 commits intoModelTC:mainfrom
huochaitiantang:update_deploy
Dec 4, 2025
Merged

Update deploy#568
helloyongyang merged 2 commits intoModelTC:mainfrom
huochaitiantang:update_deploy

Conversation

@huochaitiantang
Copy link
Collaborator

deploy 部署相关环境更新

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @huochaitiantang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在更新部署环境并提高 lightx2v 应用程序的健壮性和性能。它包含了多人物和动画功能所需的新依赖项,解决了 pyannote.audio 的特定模型加载问题,通过将阻塞操作卸载到线程池来增强服务器响应能力,并引入了一种可配置的方式来绕过 AI 设备检查。

Highlights

  • 部署环境更新: Dockerfile 已更新,以包含多人物和动画功能所需的新依赖项,并集成了 sam2 库。
  • Pyannote 模型加载修复: 通过临时修改 torch.load 的行为,确保 pyannote.audio 模型在加载时 weights_only 参数设置为 False,解决了潜在的模型加载问题。
  • FastAPI 异步处理: FastAPI 服务器中的 CPU 密集型任务(如人脸检测和音频分离)已迁移到 asyncio.to_thread,以防止阻塞主事件循环,提高服务器响应能力。
  • AI 设备检查可跳过: 引入了一个新的环境变量 SKIP_PLATFORM_CHECK,允许在特定情况下跳过 AI 设备可用性检查,提供更大的部署灵活性。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@helloyongyang helloyongyang merged commit 9597967 into ModelTC:main Dec 4, 2025
1 check passed
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 更新了部署相关的环境,主要包括:

  1. 在 Dockerfile 中添加了新的 Python 依赖和 sam2 模型的安装步骤,以支持多人和动画相关功能。
  2. 为了兼容新版本的 torch,在 audio_separator.py 中通过 monkey-patch 的方式修改了 torch.load 的行为。
  3. __main__.py 中将几个耗时的同步函数调用改为了异步执行,以避免阻塞事件循环。
  4. base.py 中增加了通过环境变量跳过 AI 设备检查的逻辑。

代码改动方向是正确的,特别是异步化的改造能提升服务性能。我提出了一些关于 Dockerfile 优化、monkey-patching 的风险以及环境变量处理方式的建议,希望能帮助提升代码质量和健壮性。

ENV PYTHONPATH=/workspace/LightX2V

# for multi-person & animate
RUN pip install ultralytics moviepy pydub pyannote.audio onnxruntime decord peft onnxruntime pandas matplotlib loguru sentencepiece
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

pip install 命令中,onnxruntime 被重复列出了两次。此外,建议使用 --no-cache-dir 选项来避免存储 pip 缓存,这样可以减小最终的 Docker 镜像体积。

RUN pip install --no-cache-dir ultralytics moviepy pydub pyannote.audio onnxruntime decord peft pandas matplotlib loguru sentencepiece

Comment on lines +17 to +23
RUN export COMMIT=0e78a118995e66bb27d78518c4bd9a3e95b4e266 \
&& export TORCH_CUDA_ARCH_LIST="9.0" \
&& git clone --depth 1 https://github.com/facebookresearch/sam2.git \
&& cd sam2 \
&& git fetch --depth 1 origin $COMMIT \
&& git checkout $COMMIT \
&& python setup.py install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

克隆的 sam2 仓库在安装后没有被移除,这会不必要地增加 Docker 镜像的大小。最佳实践是在同一个 RUN 层中清理临时文件和构建产物。建议在安装后删除 sam2 目录。

RUN export COMMIT=0e78a118995e66bb27d78518c4bd9a3e95b4e266 \
    && export TORCH_CUDA_ARCH_LIST="9.0" \
    && git clone --depth 1 https://github.com/facebookresearch/sam2.git \
    && (cd sam2 && git fetch --depth 1 origin $COMMIT && git checkout $COMMIT && python setup.py install) \
    && rm -rf sam2

is_available = platform_device.is_available()
if not is_available:
raise RuntimeError(f"AI device for platform '{platform}' is not available. Please check your runtime environment.")
skip_platform_check = os.getenv("SKIP_PLATFORM_CHECK", "False") in ["1", "True"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

对布尔类型的环境变量的检查对 "True" 是大小写敏感的,并且只考虑了有限的几个值。一个更健壮和常见的做法是以不区分大小写的方式检查各种真值。

Suggested change
skip_platform_check = os.getenv("SKIP_PLATFORM_CHECK", "False") in ["1", "True"]
skip_platform_check = os.getenv("SKIP_PLATFORM_CHECK", "false").lower() in ("true", "1", "t", "y", "yes")

@huochaitiantang huochaitiantang deleted the update_deploy branch December 16, 2025 02:24
helloyongyang pushed a commit that referenced this pull request Mar 6, 2026
deploy 部署相关环境更新
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants