From bd149ca8de69753d1865c1f6d064d627c0ea3b7c Mon Sep 17 00:00:00 2001 From: yolain Date: Tue, 4 Feb 2025 12:51:29 +0800 Subject: [PATCH] Set sd3_api to deprecated --- py/libs/stability.py | 3 +-- py/nodes/api.py | 38 ----------------------------------- py/nodes/deprecated.py | 45 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/py/libs/stability.py b/py/libs/stability.py index 26688fa..b0354ff 100644 --- a/py/libs/stability.py +++ b/py/libs/stability.py @@ -13,13 +13,13 @@ root_path = pathlib.Path(__file__).parent.parent.parent config_path = os.path.join(root_path,'config.yaml') default_key = [{'name':'Default', 'key':''}] + class StabilityAPI: def __init__(self): self.api_url = "https://api.stability.ai" self.api_keys = None self.api_current = 0 self.user_info = {} - self.getAPIKeys() def getErrors(self, code): errors = { @@ -154,7 +154,6 @@ class StabilityAPI: stableAPI = StabilityAPI() - @PromptServer.instance.routes.get("/easyuse/stability/api_keys") async def get_stability_api_keys(request): stableAPI.getAPIKeys() diff --git a/py/nodes/api.py b/py/nodes/api.py index 03ea485..0d5da5b 100644 --- a/py/nodes/api.py +++ b/py/nodes/api.py @@ -1,40 +1,4 @@ -from ..libs.stability import stableAPI -class stableDiffusion3API: - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "positive": ("STRING", {"default": "", "placeholder": "Positive", "multiline": True}), - "negative": ("STRING", {"default": "", "placeholder": "Negative", "multiline": True}), - "model": (["sd3", "sd3-turbo"],), - "aspect_ratio": (['16:9', '1:1', '21:9', '2:3', '3:2', '4:5', '5:4', '9:16', '9:21'],), - "seed": ("INT", {"default": 0, "min": 0, "max": 4294967294}), - "denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0}), - }, - "optional": { - "optional_image": ("IMAGE",), - }, - "hidden": { - "unique_id": "UNIQUE_ID", - "extra_pnginfo": "EXTRA_PNGINFO", - }, - } - - RETURN_TYPES = ("IMAGE",) - RETURN_NAMES = ("image",) - - FUNCTION = "generate" - OUTPUT_NODE = False - - CATEGORY = "EasyUse/API" - - def generate(self, positive, negative, model, aspect_ratio, seed, denoise, optional_image=None, unique_id=None, extra_pnginfo=None): - mode = 'text-to-image' - if optional_image is not None: - mode = 'image-to-image' - output_image = stableAPI.generate_sd3_image(positive, negative, aspect_ratio, seed=seed, mode=mode, model=model, strength=denoise, image=optional_image) - return (output_image,) from ..libs.fluxai import fluxaiAPI @@ -69,11 +33,9 @@ class fluxPromptGenAPI: return (prompt,) NODE_CLASS_MAPPINGS = { - "easy stableDiffusion3API": stableDiffusion3API, "easy fluxPromptGenAPI": fluxPromptGenAPI, } NODE_DISPLAY_NAME_MAPPINGS = { - "easy stableDiffusion3API": "Stable Diffusion 3 (API)", "easy fluxPromptGenAPI": "Flux Prompt Gen (API)", } \ No newline at end of file diff --git a/py/nodes/deprecated.py b/py/nodes/deprecated.py index 5268843..dbe516a 100644 --- a/py/nodes/deprecated.py +++ b/py/nodes/deprecated.py @@ -336,15 +336,56 @@ class injectNoiseToLatent: return (samples,) +from ..libs.stability import stableAPI +class stableDiffusion3API: + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "positive": ("STRING", {"default": "", "placeholder": "Positive", "multiline": True}), + "negative": ("STRING", {"default": "", "placeholder": "Negative", "multiline": True}), + "model": (["sd3", "sd3-turbo"],), + "aspect_ratio": (['16:9', '1:1', '21:9', '2:3', '3:2', '4:5', '5:4', '9:16', '9:21'],), + "seed": ("INT", {"default": 0, "min": 0, "max": 4294967294}), + "denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0}), + }, + "optional": { + "optional_image": ("IMAGE",), + }, + "hidden": { + "unique_id": "UNIQUE_ID", + "extra_pnginfo": "EXTRA_PNGINFO", + }, + } + + RETURN_TYPES = ("IMAGE",) + RETURN_NAMES = ("image",) + + FUNCTION = "generate" + OUTPUT_NODE = False + + CATEGORY = "EasyUse/🚫 Deprecated" + DEPRECATED = True + + + def generate(self, positive, negative, model, aspect_ratio, seed, denoise, optional_image=None, unique_id=None, extra_pnginfo=None): + stableAPI.getAPIKeys() + mode = 'text-to-image' + if optional_image is not None: + mode = 'image-to-image' + output_image = stableAPI.generate_sd3_image(positive, negative, aspect_ratio, seed=seed, mode=mode, model=model, strength=denoise, image=optional_image) + return (output_image,) + NODE_CLASS_MAPPINGS = { "easy if": If, "easy poseEditor": poseEditor, "easy imageToMask": imageToMask, "easy showSpentTime": showSpentTime, - # latent 潜空间 "easy latentNoisy": latentNoisy, "easy latentCompositeMaskedWithCond": latentCompositeMaskedWithCond, "easy injectNoiseToLatent": injectNoiseToLatent, + "easy stableDiffusion3API": stableDiffusion3API, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -352,8 +393,8 @@ NODE_DISPLAY_NAME_MAPPINGS = { "easy poseEditor": "PoseEditor (🚫Deprecated)", "easy imageToMask": "ImageToMask (🚫Deprecated)", "easy showSpentTime": "Show Spent Time (🚫Deprecated)", - # latent 潜空间 "easy latentNoisy": "LatentNoisy (🚫Deprecated)", "easy latentCompositeMaskedWithCond": "LatentCompositeMaskedWithCond (🚫Deprecated)", "easy injectNoiseToLatent": "InjectNoiseToLatent (🚫Deprecated)", + "easy stableDiffusion3API": "StableDiffusion3API (🚫Deprecated)", } \ No newline at end of file