add support for midjourney provider settings
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
"""
|
||||
Runware Midjourney Provider Settings Node
|
||||
Provides Midjourney-specific settings for image generation workflows.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
|
||||
|
||||
class RunwareMidjourneyProviderSettings:
|
||||
"""Runware Midjourney Provider Settings Node"""
|
||||
|
||||
QUALITY_STEP = 0.25
|
||||
QUALITY_MIN = 0.25
|
||||
QUALITY_MAX = 2.0
|
||||
DEFAULT_QUALITY = 1.0
|
||||
|
||||
DEFAULT_STYLIZE = 0
|
||||
STYLIZE_MIN = 0
|
||||
STYLIZE_MAX = 1000
|
||||
|
||||
DEFAULT_CHAOS = 0
|
||||
CHAOS_MIN = 0
|
||||
CHAOS_MAX = 100
|
||||
|
||||
DEFAULT_WEIRD = 0
|
||||
WEIRD_MIN = 0
|
||||
WEIRD_MAX = 3000
|
||||
|
||||
NIJI_OPTIONS = [
|
||||
"", # Allow provider default when omitted
|
||||
"close",
|
||||
"0",
|
||||
"5",
|
||||
"6",
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {},
|
||||
"optional": {
|
||||
"quality": ("FLOAT", {
|
||||
"tooltip": "Midjourney quality multiplier (provider key: providerSettings.midjourney.quality).",
|
||||
"default": cls.DEFAULT_QUALITY,
|
||||
"min": cls.QUALITY_MIN,
|
||||
"max": cls.QUALITY_MAX,
|
||||
"step": cls.QUALITY_STEP,
|
||||
}),
|
||||
"stylize": ("INT", {
|
||||
"tooltip": "Controls how strongly Midjourney's artistic style is applied (provider key: providerSettings.midjourney.stylize).",
|
||||
"default": cls.DEFAULT_STYLIZE,
|
||||
"min": cls.STYLIZE_MIN,
|
||||
"max": cls.STYLIZE_MAX,
|
||||
}),
|
||||
"chaos": ("INT", {
|
||||
"tooltip": "Controls variation and unpredictability (provider key: providerSettings.midjourney.chaos).",
|
||||
"default": cls.DEFAULT_CHAOS,
|
||||
"min": cls.CHAOS_MIN,
|
||||
"max": cls.CHAOS_MAX,
|
||||
}),
|
||||
"weird": ("INT", {
|
||||
"tooltip": "Adds surreal, experimental characteristics (provider key: providerSettings.midjourney.weird).",
|
||||
"default": cls.DEFAULT_WEIRD,
|
||||
"min": cls.WEIRD_MIN,
|
||||
"max": cls.WEIRD_MAX,
|
||||
}),
|
||||
"niji": (cls.NIJI_OPTIONS, {
|
||||
"tooltip": "Select the Midjourney anime-focused rendering engine (provider key: providerSettings.midjourney.niji).",
|
||||
"default": "close",
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("RUNWAREPROVIDERSETTINGS",)
|
||||
RETURN_NAMES = ("Provider Settings",)
|
||||
FUNCTION = "create_provider_settings"
|
||||
CATEGORY = "Runware/Provider Settings"
|
||||
DESCRIPTION = "Configure Midjourney-specific provider settings such as quality, stylize, chaos, weird, and niji options for image generation."
|
||||
|
||||
def create_provider_settings(self, **kwargs) -> Tuple[Optional[Dict[str, Any]],]:
|
||||
"""Build Midjourney provider settings payload."""
|
||||
|
||||
quality = kwargs.get("quality", self.DEFAULT_QUALITY)
|
||||
stylize = kwargs.get("stylize", self.DEFAULT_STYLIZE)
|
||||
chaos = kwargs.get("chaos", self.DEFAULT_CHAOS)
|
||||
weird = kwargs.get("weird", self.DEFAULT_WEIRD)
|
||||
niji = kwargs.get("niji", "close")
|
||||
|
||||
settings: Dict[str, Any] = {}
|
||||
|
||||
if quality is not None:
|
||||
settings["quality"] = float(quality)
|
||||
|
||||
if stylize is not None:
|
||||
settings["stylize"] = int(stylize)
|
||||
|
||||
if chaos is not None:
|
||||
settings["chaos"] = int(chaos)
|
||||
|
||||
if weird is not None:
|
||||
settings["weird"] = int(weird)
|
||||
|
||||
if isinstance(niji, str) and niji.strip():
|
||||
settings["niji"] = niji.strip()
|
||||
|
||||
# Clean None values so the inference request only includes populated options.
|
||||
settings = {k: v for k, v in settings.items() if v is not None}
|
||||
|
||||
return (settings if settings else None,)
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"RunwareMidjourneyProviderSettings": RunwareMidjourneyProviderSettings,
|
||||
}
|
||||
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"RunwareMidjourneyProviderSettings": "Runware Midjourney Provider Settings",
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ def getCustomEndpoint():
|
||||
custom_endpoint = os.getenv("RUNWARE_CUSTOM_ENDPOINT")
|
||||
if custom_endpoint and isinstance(custom_endpoint, str):
|
||||
return custom_endpoint
|
||||
return "https://api.runware.ai/v1"
|
||||
return "https://api.runware.dev/v1"
|
||||
|
||||
SESSION_TIMEOUT = getTimeout()
|
||||
RUNWARE_API_KEY = getAPIKey()
|
||||
|
||||
+31
-19
@@ -14,16 +14,22 @@ class videoUpscaler:
|
||||
"Video": ("STRING", {
|
||||
"tooltip": "MediaUUID from Runware Media Upload node for the video to upscale."
|
||||
}),
|
||||
"upscaleFactor": ([2, 4], {
|
||||
"tooltip": "Integer scale factor for upscaling (2x or 4x).",
|
||||
"default": 2,
|
||||
}),
|
||||
"Model": (list(cls.RUNWARE_VUPSCALER_MODELS.keys()), {
|
||||
"tooltip": "Select the video upscaler model to use.",
|
||||
"default": "Bria Video Upscaler",
|
||||
}),
|
||||
"useUpscaleFactor": ("BOOLEAN", {
|
||||
"label_on": "Yes",
|
||||
"label_off": "No",
|
||||
"tooltip": "Enable to explicitly set the upscale factor for the request.",
|
||||
"default": False,
|
||||
}),
|
||||
},
|
||||
"optional": {
|
||||
"upscaleFactor": ([2, 4], {
|
||||
"tooltip": "Integer scale factor for upscaling (2x or 4x).",
|
||||
"default": 2,
|
||||
}),
|
||||
"Output Format": (["mp4", "webm"], {
|
||||
"default": "mp4",
|
||||
"tooltip": "Choose the output video format.",
|
||||
@@ -39,7 +45,8 @@ class videoUpscaler:
|
||||
|
||||
def upscale(self, **kwargs):
|
||||
video_uuid = kwargs.get("Video")
|
||||
upscaleFactor = kwargs.get("upscaleFactor", 2)
|
||||
useUpscaleFactor = kwargs.get("useUpscaleFactor", False)
|
||||
upscaleFactor = kwargs.get("upscaleFactor")
|
||||
modelName = kwargs.get("Model", "Bria Video Upscaler")
|
||||
outputFormat = kwargs.get("Output Format", "mp4")
|
||||
|
||||
@@ -51,20 +58,25 @@ class videoUpscaler:
|
||||
modelAIR = self.RUNWARE_VUPSCALER_MODELS.get(modelName, "bria:50@1")
|
||||
|
||||
# Build the API request
|
||||
genConfig = [
|
||||
{
|
||||
"taskType": "upscale",
|
||||
"taskUUID": rwUtils.genRandUUID(),
|
||||
"upscaleFactor": upscaleFactor,
|
||||
"inputs": {
|
||||
"video": video_uuid
|
||||
},
|
||||
"outputType": "URL",
|
||||
"outputFormat": outputFormat.upper(),
|
||||
"model": modelAIR,
|
||||
"includeCost": True
|
||||
}
|
||||
]
|
||||
task_payload = {
|
||||
"taskType": "upscale",
|
||||
"taskUUID": rwUtils.genRandUUID(),
|
||||
"inputs": {
|
||||
"video": video_uuid
|
||||
},
|
||||
"outputType": "URL",
|
||||
"outputFormat": outputFormat.upper(),
|
||||
"model": modelAIR,
|
||||
"includeCost": True
|
||||
}
|
||||
|
||||
if useUpscaleFactor:
|
||||
if upscaleFactor in (2, 4):
|
||||
task_payload["upscaleFactor"] = upscaleFactor
|
||||
else:
|
||||
raise ValueError("upscaleFactor must be 2 or 4 when useUpscaleFactor is enabled.")
|
||||
|
||||
genConfig = [task_payload]
|
||||
|
||||
try:
|
||||
# Debug: Print the request being sent
|
||||
|
||||
Reference in New Issue
Block a user