add modal serving file
This commit is contained in:
52
pyproject.toml
Normal file
52
pyproject.toml
Normal file
@@ -0,0 +1,52 @@
|
||||
[project]
|
||||
name = "wan2gp"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
"accelerate>=1.1.1",
|
||||
"av>=15.0.0",
|
||||
"dashscope>=1.24.0",
|
||||
"decord>=0.6.0",
|
||||
"diffusers>=0.31.0",
|
||||
"easydict>=1.13",
|
||||
"einops>=0.8.1",
|
||||
"ffmpeg-python>=0.2.0",
|
||||
"ftfy>=6.3.1",
|
||||
"gradio==5.23.0",
|
||||
"hydra-core>=1.3.2",
|
||||
"imageio>=2.37.0",
|
||||
"imageio-ffmpeg>=0.6.0",
|
||||
"librosa==0.11.0",
|
||||
"loguru>=0.7.3",
|
||||
"matplotlib>=3.10.3",
|
||||
"misaki>=0.9.4",
|
||||
"mmgp==3.5.1",
|
||||
"modal>=1.1.0",
|
||||
"moviepy==1.0.3",
|
||||
"mutagen>=1.47.0",
|
||||
"numpy>=1.23.5,<2",
|
||||
"omegaconf>=2.3.0",
|
||||
"onnxruntime-gpu>=1.22.0",
|
||||
"open-clip-torch>=2.29.0",
|
||||
"opencv-python>=4.9.0.80",
|
||||
"peft==0.15.0",
|
||||
"pyannote-audio>=3.3.2",
|
||||
"pydantic==2.10.6",
|
||||
"pygame>=2.1.0",
|
||||
"pyloudnorm>=0.1.1",
|
||||
"rembg[gpu]==2.0.65",
|
||||
"segment-anything>=1.0",
|
||||
"sentencepiece>=0.2.0",
|
||||
"sounddevice>=0.4.0",
|
||||
"soundfile>=0.13.1",
|
||||
"tensordict>=0.6.1",
|
||||
"timm>=1.0.19",
|
||||
"tokenizers>=0.20.3",
|
||||
"torch>=2.4.0",
|
||||
"torchdiffeq>=0.2.5",
|
||||
"torchvision>=0.19.0",
|
||||
"tqdm>=4.67.1",
|
||||
"transformers==4.51.3",
|
||||
]
|
||||
|
||||
67
serve.py
Normal file
67
serve.py
Normal file
@@ -0,0 +1,67 @@
|
||||
import modal
|
||||
|
||||
image = (
|
||||
modal.Image.debian_slim()
|
||||
.apt_install("libgl1", "libglib2.0-0", "libsm6", "libxrender1", "libxext6", "ffmpeg")
|
||||
.pip_install("torch", "torchvision", "torchaudio", index_url="https://download.pytorch.org/whl/cu128")
|
||||
.pip_install_from_pyproject("./pyproject.toml")
|
||||
.pip_install("sageattention")
|
||||
.add_local_dir(local_path="../Wan2GP", remote_path="/root/Wan2GP", ignore=["*.venv"])
|
||||
)
|
||||
|
||||
app = modal.App(name="Wan2GP", image=image)
|
||||
|
||||
vol = modal.Volume.from_name("wan2gp-ckpts", create_if_missing=True, environment_name="dev")
|
||||
outputs = modal.Volume.from_name("wan2gp-outputs", create_if_missing=True, environment_name="dev")
|
||||
|
||||
with image.imports():
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
||||
# @app.function(max_containers=1, gpu="L40S",
|
||||
# scaledown_window=900,
|
||||
# timeout=3600,
|
||||
# volumes={"/root/Wan2GP/ckpts": vol,
|
||||
# "/root/Wan2GP/outputs": outputs})
|
||||
# @modal.concurrent(max_inputs=50)
|
||||
# @modal.web_server(8000, startup_timeout=2400)
|
||||
# def ui():
|
||||
# os.chdir("/root/Wan2GP")
|
||||
# subprocess.Popen(
|
||||
# "python /root/Wan2GP/wgp.py --listen --server-port 8000 --compile --attention sage --profile 1",
|
||||
# shell=True)
|
||||
|
||||
@app.function(max_containers=1, gpu="L40S",
|
||||
scaledown_window=900,
|
||||
timeout=60 * 60 * 18,
|
||||
volumes={"/root/Wan2GP/ckpts": vol,
|
||||
"/root/Wan2GP/outputs": outputs})
|
||||
@modal.concurrent(max_inputs=1000)
|
||||
@modal.asgi_app()
|
||||
def serve():
|
||||
import asyncio
|
||||
import atexit
|
||||
from fastapi import FastAPI
|
||||
from gradio import mount_gradio_app
|
||||
os.chdir("/root/Wan2GP")
|
||||
import sys
|
||||
sys.path.append('/root/Wan2GP')
|
||||
sys.argv = ["--listen", "--server-port", "8000", "--compile", "--attention", "sage", "--profile", "1"]
|
||||
from wgp import autosave_queue, create_ui, save_path
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
atexit.register(autosave_queue)
|
||||
# download_ffmpeg()
|
||||
# threading.Thread(target=runner, daemon=True).start()
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
server_port = 8000
|
||||
if os.name == "nt":
|
||||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||
server_name = "0.0.0.0"
|
||||
demo = create_ui()
|
||||
demo.queue(max_size=5)
|
||||
return mount_gradio_app(app=app, blocks=demo, path="/",
|
||||
server_name=server_name, server_port=server_port,
|
||||
allowed_paths=[save_path])
|
||||
Reference in New Issue
Block a user