80 lines
2.9 KiB
Python
80 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
File video_agent_deploy.py
|
|
Author charon
|
|
Date 2025/9/6 18:15
|
|
"""
|
|
|
|
import os
|
|
import subprocess
|
|
import modal
|
|
|
|
image = (
|
|
modal.Image.debian_slim(
|
|
python_version="3.10"
|
|
)
|
|
.apt_install("git", "gcc", "libportaudio2", "ffmpeg")
|
|
.pip_install("comfy_cli")
|
|
.run_commands(
|
|
"comfy --skip-prompt install --fast-deps --nvidia --version 0.3.55"
|
|
)
|
|
.pip_install_from_pyproject(os.path.join(os.path.dirname(__file__), "pyproject.toml"))
|
|
.run_commands("comfy node install https://github.com/yolain/ComfyUI-Easy-Use.git")
|
|
.run_commands("comfy node install https://github.com/crystian/ComfyUI-Crystools.git")
|
|
.run_commands("comfy node install https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git")
|
|
.run_commands("comfy node install https://github.com/kijai/ComfyUI-KJNodes.git")
|
|
.run_commands("comfy node install https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git")
|
|
.run_commands("comfy node install https://github.com/WASasquatch/was-node-suite-comfyui.git")
|
|
.run_commands("comfy node install https://github.com/cubiq/ComfyUI_essentials.git")
|
|
.add_local_dir(local_path=r'D:\code\ComfyUI-CustomNode',
|
|
remote_path='/root/comfy/ComfyUI/custom_nodes',
|
|
copy=True
|
|
)
|
|
.run_commands("comfy node install https://github.com/jamesWalker55/comfyui-various.git")
|
|
# .run_commands("comfy node install https://gitea.bowongai.com/bowong/ComfyUI-CustomNode.git", force_build=True)
|
|
.run_commands("comfy node install https://github.com/rgthree/rgthree-comfy.git")
|
|
.run_commands("rm -rf /root/comfy/ComfyUI/models&&ln -s /models /root/comfy/ComfyUI/models")
|
|
.run_commands("rm -rf /root/comfy/ComfyUI/input&&ln -s /models/input /root/comfy/ComfyUI/input")
|
|
.run_commands("rm -rf /root/comfy/ComfyUI/output&&ln -s /models/output /root/comfy/ComfyUI/output")
|
|
)
|
|
app = modal.App(image=image, name='cf-video-api')
|
|
custom_secret = modal.Secret.from_name("comfyui-custom-secret", environment_name="dev")
|
|
vol = modal.Volume.from_name("comfy_model", environment_name="dev", create_if_missing=True)
|
|
|
|
|
|
@app.function(
|
|
min_containers=0,
|
|
buffer_containers=0,
|
|
max_containers=1,
|
|
scaledown_window=600,
|
|
secrets=[custom_secret],
|
|
volumes={
|
|
"/models": vol
|
|
}
|
|
)
|
|
@modal.concurrent(
|
|
max_inputs=10
|
|
)
|
|
@modal.web_server(8000, startup_timeout=120, label='image-video-agent-1')
|
|
def ui_1():
|
|
process = subprocess.Popen("comfy launch -- --cpu --listen 0.0.0.0 --port 8000", shell=True)
|
|
process.wait()
|
|
|
|
|
|
@app.function(
|
|
min_containers=0,
|
|
buffer_containers=0,
|
|
max_containers=1,
|
|
scaledown_window=600,
|
|
secrets=[custom_secret],
|
|
volumes={
|
|
"/models": vol
|
|
}
|
|
)
|
|
@modal.concurrent(
|
|
max_inputs=10
|
|
)
|
|
@modal.web_server(8000, startup_timeout=120, label='image-video-agent-2')
|
|
def ui_2():
|
|
subprocess.Popen("comfy launch -- --cpu --listen 0.0.0.0 --port 8000", shell=True)
|