|
|
import os
|
|
|
import sys
|
|
|
import time
|
|
|
|
|
|
import torch
|
|
|
|
|
|
current_file_path = os.path.abspath(__file__)
|
|
|
project_roots = [os.path.dirname(current_file_path), os.path.dirname(os.path.dirname(current_file_path)), os.path.dirname(os.path.dirname(os.path.dirname(current_file_path)))]
|
|
|
for project_root in project_roots:
|
|
|
sys.path.insert(0, project_root) if project_root not in sys.path else None
|
|
|
|
|
|
from cogvideox.api.api import (infer_forward_api,
|
|
|
update_diffusion_transformer_api,
|
|
|
update_edition_api)
|
|
|
from cogvideox.ui.controller import flow_scheduler_dict
|
|
|
from cogvideox.ui.wan_ui import ui, ui_eas, ui_modelscope
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
ui_mode = "normal"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPU_memory_mode = "sequential_cpu_offload"
|
|
|
|
|
|
|
|
|
weight_dtype = torch.bfloat16
|
|
|
|
|
|
config_path = "config/wan2.1/wan_civitai.yaml"
|
|
|
|
|
|
|
|
|
server_name = "0.0.0.0"
|
|
|
server_port = 7860
|
|
|
|
|
|
|
|
|
model_name = "models/Diffusion_Transformer/Wan2.1-I2V-14B-480P"
|
|
|
|
|
|
model_type = "Inpaint"
|
|
|
|
|
|
savedir_sample = "samples"
|
|
|
|
|
|
if ui_mode == "modelscope":
|
|
|
demo, controller = ui_modelscope(model_name, model_type, savedir_sample, GPU_memory_mode, flow_scheduler_dict, weight_dtype, config_path)
|
|
|
elif ui_mode == "eas":
|
|
|
demo, controller = ui_eas(model_name, flow_scheduler_dict, savedir_sample, config_path)
|
|
|
else:
|
|
|
demo, controller = ui(GPU_memory_mode, flow_scheduler_dict, weight_dtype, config_path)
|
|
|
|
|
|
|
|
|
app, _, _ = demo.queue(status_update_rate=1).launch(
|
|
|
server_name=server_name,
|
|
|
server_port=server_port,
|
|
|
prevent_thread_lock=True
|
|
|
)
|
|
|
|
|
|
|
|
|
infer_forward_api(None, app, controller)
|
|
|
update_diffusion_transformer_api(None, app, controller)
|
|
|
update_edition_api(None, app, controller)
|
|
|
|
|
|
|
|
|
while True:
|
|
|
time.sleep(5) |