Add resolution parameter support for video models
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
Runware Alibaba Provider Settings Node
|
||||
Provides Alibaba-specific settings for image/video generation
|
||||
"""
|
||||
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
|
||||
class RunwareAlibabaProviderSettings:
|
||||
"""Runware Alibaba Provider Settings Node"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {},
|
||||
"optional": {
|
||||
"usePromptEnhancer": ("BOOLEAN", {
|
||||
"tooltip": "Enable to include promptEnhancer parameter in provider settings",
|
||||
"default": False,
|
||||
}),
|
||||
"promptEnhancer": ("BOOLEAN", {
|
||||
"tooltip": "Enable prompt enhancement for Alibaba generation. Only used when 'Use Prompt Enhancer' is enabled.",
|
||||
"default": False,
|
||||
"label_on": "Enabled",
|
||||
"label_off": "Disabled",
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("RUNWAREPROVIDERSETTINGS",)
|
||||
RETURN_NAMES = ("Provider Settings",)
|
||||
FUNCTION = "createProviderSettings"
|
||||
CATEGORY = "Runware/Provider Settings"
|
||||
DESCRIPTION = "Configure Alibaba-specific provider settings for image/video generation including prompt enhancement."
|
||||
|
||||
def createProviderSettings(self, **kwargs) -> tuple[Dict[str, Any]]:
|
||||
"""Create Alibaba provider settings"""
|
||||
|
||||
# Get control parameters
|
||||
usePromptEnhancer = kwargs.get("usePromptEnhancer", False)
|
||||
|
||||
# Get value parameters
|
||||
promptEnhancer = kwargs.get("promptEnhancer", False)
|
||||
|
||||
# Build settings dictionary - only include what is enabled
|
||||
alibabaSettings: Dict[str, Any] = {}
|
||||
|
||||
# Add promptEnhancer only if usePromptEnhancer is enabled
|
||||
if usePromptEnhancer:
|
||||
alibabaSettings["promptEnhancer"] = promptEnhancer
|
||||
|
||||
# Clean up None values
|
||||
alibabaSettings = {k: v for k, v in alibabaSettings.items() if v is not None}
|
||||
|
||||
# Return flat dictionary - will be wrapped by inference node with provider name
|
||||
return (alibabaSettings,)
|
||||
|
||||
|
||||
# Node class mappings
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"RunwareAlibabaProviderSettings": RunwareAlibabaProviderSettings,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"RunwareAlibabaProviderSettings": "Runware Alibaba Provider Settings",
|
||||
}
|
||||
|
||||
@@ -175,10 +175,14 @@ class txt2vid:
|
||||
model = runwareVideoModel.get("model", "")
|
||||
width = runwareVideoModel.get("width")
|
||||
height = runwareVideoModel.get("height")
|
||||
useResolution = runwareVideoModel.get("useResolution", False)
|
||||
resolution = runwareVideoModel.get("resolution", None)
|
||||
else:
|
||||
model = runwareVideoModel
|
||||
width = None
|
||||
height = None
|
||||
useResolution = False
|
||||
resolution = None
|
||||
|
||||
genConfig = [
|
||||
{
|
||||
@@ -190,6 +194,12 @@ class txt2vid:
|
||||
"includeCost": True,
|
||||
}
|
||||
]
|
||||
|
||||
# Add resolution if enabled
|
||||
if useResolution and resolution:
|
||||
genConfig[0]["resolution"] = resolution
|
||||
|
||||
# Add width/height if not using resolution (or if resolution is not provided)
|
||||
if (
|
||||
width is not None and height is not None
|
||||
and width > 0 and height > 0
|
||||
|
||||
+101
-2
@@ -158,6 +158,84 @@ class videoModelSearch:
|
||||
"lumaai:2@2": {"width": 1080, "height": 720},
|
||||
}
|
||||
|
||||
# Model resolutions mapping
|
||||
MODEL_RESOLUTIONS = {
|
||||
# KlingAI Models
|
||||
"klingai:1@2": "720p",
|
||||
"klingai:1@1": "720p",
|
||||
"klingai:2@2": "1080p",
|
||||
"klingai:2@1": "720p",
|
||||
"klingai:3@1": "720p",
|
||||
"klingai:3@2": "1080p",
|
||||
"klingai:4@3": "720p",
|
||||
"klingai:5@1": "720p",
|
||||
"klingai:5@2": "1080p",
|
||||
"klingai:5@3": "1080p",
|
||||
"klingai:6@1": "1080p",
|
||||
"klingai:7@1": None, # No resolution support
|
||||
"klingai:kling@o1": None, # No standard resolution (1440x1440)
|
||||
|
||||
# Veo Models
|
||||
"google:2@0": "720p",
|
||||
"google:3@0": "720p",
|
||||
"google:3@1": "720p",
|
||||
"google:3@2": "720p",
|
||||
"google:3@3": "720p",
|
||||
|
||||
# Bytedance Models
|
||||
"bytedance:2@1": "480p",
|
||||
"bytedance:1@1": "480p",
|
||||
"bytedance:5@1": None, # No resolution support (fixed 1024x1024)
|
||||
"bytedance:5@2": None, # No resolution support (fixed 1024x1024)
|
||||
|
||||
# MiniMax Models (support both 768p and 720p, using 768p as primary)
|
||||
"minimax:1@1": "768p",
|
||||
"minimax:2@1": "768p",
|
||||
"minimax:2@3": "768p",
|
||||
"minimax:3@1": "768p",
|
||||
"minimax:4@1": "768p",
|
||||
"minimax:4@2": "768p",
|
||||
|
||||
# PixVerse Models
|
||||
"pixverse:1@1": "360p",
|
||||
"pixverse:1@2": "360p",
|
||||
"pixverse:1@3": "360p",
|
||||
"pixverse:1@6": "360p",
|
||||
"pixverse:lipsync@1": "360p",
|
||||
|
||||
# Vidu Models
|
||||
"vidu:1@0": "1080p",
|
||||
"vidu:1@1": "1080p",
|
||||
"vidu:1@5": "1080p",
|
||||
"vidu:2@0": "1080p",
|
||||
|
||||
# Wan Models
|
||||
"runware:200@1": "480p",
|
||||
"runware:200@2": "480p",
|
||||
"runware:200@6": "720p",
|
||||
|
||||
# OpenAI Models
|
||||
"openai:3@1": "720p",
|
||||
"openai:3@0": "720p",
|
||||
|
||||
# Lightricks Models
|
||||
"lightricks:2@0": "1080p",
|
||||
"lightricks:2@1": "1080p",
|
||||
"lightricks:3@1": None, # No resolution support
|
||||
|
||||
# Ovi Models
|
||||
"runware:190@1": None, # No resolution support
|
||||
|
||||
# Runway Models
|
||||
"runway:2@1": "720p",
|
||||
"runway:1@1": "720p",
|
||||
|
||||
# Luma Models
|
||||
"lumaai:1@1": "720p",
|
||||
"lumaai:2@1": "720p",
|
||||
"lumaai:2@2": "720p",
|
||||
}
|
||||
|
||||
MODEL_ARCHITECTURES = [
|
||||
"All",
|
||||
"KlingAI",
|
||||
@@ -182,6 +260,7 @@ class videoModelSearch:
|
||||
defaultModel = "klingai:5@3 (KlingAI V2.0 Master)"
|
||||
defaultModelCode = defaultModel.split(" (")[0]
|
||||
defaultDims = cls.MODEL_DIMENSIONS.get(defaultModelCode, cls.DEFAULT_DIMENSIONS)
|
||||
defaultResolution = cls.MODEL_RESOLUTIONS.get(defaultModelCode, None)
|
||||
|
||||
return {
|
||||
"required": {
|
||||
@@ -220,6 +299,14 @@ class videoModelSearch:
|
||||
"step": 1,
|
||||
"tooltip": "Custom Height For The Selected Model. Defaults To Model's Recommended Height.",
|
||||
}),
|
||||
"useResolution": ("BOOLEAN", {
|
||||
"tooltip": "Enable to include resolution parameter in API request. Disable if your model doesn't support resolution.",
|
||||
"default": False,
|
||||
}),
|
||||
"resolution": (["360p", "480p", "720p", "768p", "1080p"], {
|
||||
"tooltip": "Select a standard resolution for Video Inference. Only used when 'Use Resolution' is enabled.",
|
||||
"default": defaultResolution if defaultResolution else "720p",
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -248,6 +335,8 @@ class videoModelSearch:
|
||||
customWidth = kwargs.get("Width", 0)
|
||||
customHeight = kwargs.get("Height", 0)
|
||||
useCustomDimensions = kwargs.get("useCustomDimensions", "Model Default")
|
||||
useResolution = kwargs.get("useResolution", False)
|
||||
resolution = kwargs.get("resolution", "720p")
|
||||
|
||||
if enableSearchValue:
|
||||
modelAirCode = searchInput
|
||||
@@ -256,6 +345,7 @@ class videoModelSearch:
|
||||
modelAirCode = currentModel.split(" (")[0]
|
||||
|
||||
dimensions = self.MODEL_DIMENSIONS.get(modelAirCode, self.DEFAULT_DIMENSIONS)
|
||||
modelResolution = self.MODEL_RESOLUTIONS.get(modelAirCode, None)
|
||||
|
||||
if useCustomDimensions == "Custom":
|
||||
# Use custom dimensions from Width/Height widgets
|
||||
@@ -276,9 +366,18 @@ class videoModelSearch:
|
||||
returnWidth = width
|
||||
returnHeight = height
|
||||
|
||||
return ({
|
||||
resultDict = {
|
||||
"model": modelAirCode,
|
||||
"useCustomDimensions": useCustomDimensions,
|
||||
"width": width,
|
||||
"height": height,
|
||||
}, returnWidth, returnHeight)
|
||||
}
|
||||
|
||||
# Add resolution if enabled and model supports it
|
||||
if useResolution and modelResolution is not None:
|
||||
resultDict["resolution"] = resolution
|
||||
resultDict["useResolution"] = True
|
||||
else:
|
||||
resultDict["useResolution"] = False
|
||||
|
||||
return (resultDict, returnWidth, returnHeight)
|
||||
|
||||
Reference in New Issue
Block a user