diff --git a/README.md b/README.md index 192f7a5..6f31a7e 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This is a direct integration with Alibaba Cloud's Model Studio service, not a th ## Regional Support -This node supports both international and Mainland China Alibaba Cloud regions. By default, it uses the international region endpoints, but you can easily switch to Mainland China endpoints by modifying the variables in `wan_base.py`: +This node supports both international and Mainland China Alibaba Cloud regions. By default, it uses the international region endpoints, but you can easily switch to Mainland China endpoints by modifying the variables in `core/base.py`: - **International Region** (default): - Video POST: `https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis` @@ -42,11 +42,11 @@ This node supports both international and Mainland China Alibaba Cloud regions. - T2I POST: `https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis` - GET: `https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}` -To switch regions, simply modify the `API_ENDPOINT_POST_VIDEO`, `API_ENDPOINT_POST_II2V`, `API_ENDPOINT_POST_T2I`, and `API_ENDPOINT_GET` variables in `wan_base.py` to the corresponding Mainland China endpoints listed above. +To switch regions, simply modify the `API_ENDPOINT_POST_VIDEO`, `API_ENDPOINT_POST_II2V`, `API_ENDPOINT_POST_T2I`, and `API_ENDPOINT_GET` variables in `core/base.py` to the corresponding Mainland China endpoints listed above. ## Centralized Endpoint Management -All API endpoints are centrally managed in the `wan_base.py` file, making it easy to maintain and switch between regions. This approach ensures consistency across all nodes and simplifies future updates. The centralized management includes: +All API endpoints are centrally managed in the `core/base.py` file, making it easy to maintain and switch between regions. This approach ensures consistency across all nodes and simplifies future updates. The centralized management includes: - `API_ENDPOINT_POST_VIDEO`: For general video generation nodes (I2V, T2V, VACE) - `API_ENDPOINT_POST_II2V`: For image-to-video with first/last frames (II2V) diff --git a/__init__.py b/__init__.py index 13a2868..20849d1 100644 --- a/__init__.py +++ b/__init__.py @@ -1,17 +1,17 @@ """ ComfyUI_Wan - A custom node for ComfyUI that integrates Wan models -for text-to-image, image-to-video, and text-to-video generation. +for text-to-image, image-to-video, text-to-video, first-last-frame-tovideo, and VACE generation. """ -from .wan_t2i import WanT2IGenerator -from .wan_i2v import WanI2VGenerator -from .wan_t2v import WanT2VGenerator -from .wan_ii2v import WanII2VGenerator -from .wan_vace_image_reference import WanVACEImageReference -from .wan_vace_video_repainting import WanVACEVideoRepainting -from .wan_vace_video_edit import WanVACEVideoEdit -from .wan_vace_video_extension import WanVACEVideoExtension -from .wan_vace_video_outpainting import WanVACEVideoOutpainting +from .generators.t2i import WanT2IGenerator +from .generators.i2v import WanI2VGenerator +from .generators.t2v import WanT2VGenerator +from .generators.ii2v import WanII2VGenerator +from .vace.image_reference import WanVACEImageReference +from .vace.video_repainting import WanVACEVideoRepainting +from .vace.video_edit import WanVACEVideoEdit +from .vace.video_extension import WanVACEVideoExtension +from .vace.video_outpainting import WanVACEVideoOutpainting NODE_CLASS_MAPPINGS = { "WanT2IGenerator": WanT2IGenerator, diff --git a/.env.template b/config/.env.template similarity index 100% rename from .env.template rename to config/.env.template diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..0615d93 --- /dev/null +++ b/config/__init__.py @@ -0,0 +1 @@ +# Configuration module \ No newline at end of file diff --git a/core/__init__.py b/core/__init__.py new file mode 100644 index 0000000..890be7c --- /dev/null +++ b/core/__init__.py @@ -0,0 +1,3 @@ +from .base import WanAPIBase, COMFYUI_AVAILABLE + +__all__ = ['WanAPIBase', 'COMFYUI_AVAILABLE'] \ No newline at end of file diff --git a/wan_base.py b/core/base.py similarity index 100% rename from wan_base.py rename to core/base.py diff --git a/generators/__init__.py b/generators/__init__.py new file mode 100644 index 0000000..a9288e4 --- /dev/null +++ b/generators/__init__.py @@ -0,0 +1,6 @@ +from .t2i import WanT2IGenerator +from .i2v import WanI2VGenerator +from .t2v import WanT2VGenerator +from .ii2v import WanII2VGenerator + +__all__ = ['WanT2IGenerator', 'WanI2VGenerator', 'WanT2VGenerator', 'WanII2VGenerator'] \ No newline at end of file diff --git a/wan_i2v.py b/generators/i2v.py similarity index 99% rename from wan_i2v.py rename to generators/i2v.py index 12707b2..a61aca6 100644 --- a/wan_i2v.py +++ b/generators/i2v.py @@ -12,7 +12,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -39,7 +39,7 @@ class WanI2VGenerator(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py self.api_url = self.API_ENDPOINT_POST_VIDEO @classmethod @@ -185,7 +185,7 @@ class WanI2VGenerator(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_ii2v.py b/generators/ii2v.py similarity index 99% rename from wan_ii2v.py rename to generators/ii2v.py index 46d3b31..64f4cfa 100644 --- a/wan_ii2v.py +++ b/generators/ii2v.py @@ -12,7 +12,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -36,7 +36,7 @@ class WanII2VGenerator(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_II2V in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_II2V in core/base.py self.api_url = self.API_ENDPOINT_POST_II2V @classmethod @@ -186,7 +186,7 @@ class WanII2VGenerator(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_t2i.py b/generators/t2i.py similarity index 99% rename from wan_t2i.py rename to generators/t2i.py index 67295bb..8fda597 100644 --- a/wan_t2i.py +++ b/generators/t2i.py @@ -11,7 +11,7 @@ import sys import pathlib # Import the base class -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -43,7 +43,7 @@ class WanT2IGenerator(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_T2I in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_T2I in core/base.py self.api_url = self.API_ENDPOINT_POST_T2I self.model = "wan2.2-t2i-flash" # Using Wan Speed Edition as default @@ -187,7 +187,7 @@ class WanT2IGenerator(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_t2v.py b/generators/t2v.py similarity index 99% rename from wan_t2v.py rename to generators/t2v.py index 2866cd0..e1b98af 100644 --- a/wan_t2v.py +++ b/generators/t2v.py @@ -12,7 +12,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -37,7 +37,7 @@ class WanT2VGenerator(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py self.api_url = self.API_ENDPOINT_POST_VIDEO @classmethod @@ -199,7 +199,7 @@ class WanT2VGenerator(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/vace/__init__.py b/vace/__init__.py new file mode 100644 index 0000000..be4bdb3 --- /dev/null +++ b/vace/__init__.py @@ -0,0 +1,8 @@ +from .image_reference import WanVACEImageReference +from .video_repainting import WanVACEVideoRepainting +from .video_edit import WanVACEVideoEdit +from .video_extension import WanVACEVideoExtension +from .video_outpainting import WanVACEVideoOutpainting + +__all__ = ['WanVACEImageReference', 'WanVACEVideoRepainting', 'WanVACEVideoEdit', + 'WanVACEVideoExtension', 'WanVACEVideoOutpainting'] \ No newline at end of file diff --git a/wan_vace_image_reference.py b/vace/image_reference.py similarity index 99% rename from wan_vace_image_reference.py rename to vace/image_reference.py index 4dcc576..d4e19e6 100644 --- a/wan_vace_image_reference.py +++ b/vace/image_reference.py @@ -16,7 +16,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -44,7 +44,7 @@ class WanVACEImageReference(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py self.api_url = self.API_ENDPOINT_POST_VIDEO @classmethod @@ -222,7 +222,7 @@ class WanVACEImageReference(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_vace_video_edit.py b/vace/video_edit.py similarity index 99% rename from wan_vace_video_edit.py rename to vace/video_edit.py index aa558d6..d861e28 100644 --- a/wan_vace_video_edit.py +++ b/vace/video_edit.py @@ -16,7 +16,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -66,7 +66,7 @@ class WanVACEVideoEdit(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py self.api_url = self.API_ENDPOINT_POST_VIDEO @classmethod @@ -273,7 +273,7 @@ class WanVACEVideoEdit(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_vace_video_extension.py b/vace/video_extension.py similarity index 99% rename from wan_vace_video_extension.py rename to vace/video_extension.py index 089bd66..db9010e 100644 --- a/wan_vace_video_extension.py +++ b/vace/video_extension.py @@ -16,7 +16,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -44,7 +44,7 @@ class WanVACEVideoExtension(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py self.api_url = self.API_ENDPOINT_POST_VIDEO @classmethod @@ -227,7 +227,7 @@ class WanVACEVideoExtension(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_vace_video_outpainting.py b/vace/video_outpainting.py similarity index 99% rename from wan_vace_video_outpainting.py rename to vace/video_outpainting.py index b451752..d0c287e 100644 --- a/wan_vace_video_outpainting.py +++ b/vace/video_outpainting.py @@ -16,7 +16,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -35,7 +35,7 @@ class WanVACEVideoOutpainting(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py self.api_url = self.API_ENDPOINT_POST_VIDEO @classmethod @@ -210,7 +210,7 @@ class WanVACEVideoOutpainting(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_vace_video_repainting.py b/vace/video_repainting.py similarity index 99% rename from wan_vace_video_repainting.py rename to vace/video_repainting.py index 708a3bf..2b298fa 100644 --- a/wan_vace_video_repainting.py +++ b/vace/video_repainting.py @@ -16,7 +16,7 @@ import pathlib from datetime import datetime # Import the base class and COMFYUI_AVAILABLE flag -from .wan_base import WanAPIBase, COMFYUI_AVAILABLE +from ..core.base import WanAPIBase, COMFYUI_AVAILABLE # Try to import folder_paths if available try: @@ -43,7 +43,7 @@ class WanVACEVideoRepainting(WanAPIBase): def __init__(self): super().__init__() # Use the centralized API endpoint from the base class - # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py self.api_url = self.API_ENDPOINT_POST_VIDEO @classmethod @@ -208,7 +208,7 @@ class WanVACEVideoRepainting(WanAPIBase): import time # URL for querying task results - # To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py + # To use Mainland China region, modify API_ENDPOINT_GET in core/base.py query_url = self.API_ENDPOINT_GET.format(task_id=task_id) headers = { diff --git a/wan_nodes.py b/wan_nodes.py index 4dee274..0034028 100644 --- a/wan_nodes.py +++ b/wan_nodes.py @@ -2,15 +2,15 @@ Backward compatibility module - imports all Wan nodes from their separate modules. """ -from .wan_t2i import WanT2IGenerator -from .wan_i2v import WanI2VGenerator -from .wan_t2v import WanT2VGenerator -from .wan_ii2v import WanII2VGenerator -from .wan_vace_image_reference import WanVACEImageReference -from .wan_vace_video_repainting import WanVACEVideoRepainting -from .wan_vace_video_edit import WanVACEVideoEdit -from .wan_vace_video_extension import WanVACEVideoExtension -from .wan_vace_video_outpainting import WanVACEVideoOutpainting +from .generators.t2i import WanT2IGenerator +from .generators.i2v import WanI2VGenerator +from .generators.t2v import WanT2VGenerator +from .generators.ii2v import WanII2VGenerator +from .vace.image_reference import WanVACEImageReference +from .vace.video_repainting import WanVACEVideoRepainting +from .vace.video_edit import WanVACEVideoEdit +from .vace.video_extension import WanVACEVideoExtension +from .vace.video_outpainting import WanVACEVideoOutpainting __all__ = ['WanT2IGenerator', 'WanI2VGenerator', 'WanT2VGenerator', 'WanII2VGenerator', 'WanVACEImageReference', 'WanVACEVideoRepainting', 'WanVACEVideoEdit',