diff --git a/README.md b/README.md index 757fd543..3392f493 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ - [2024/08/01] 🌩️ [BizyAir MinusZone Kolors](https://siliconflow.github.io/BizyAir/kolors/introduce.html) nodes have been released(thanks to [MinusZoneAI/ComfyUI-Kolors-MZ](https://github.com/MinusZoneAI/ComfyUI-Kolors-MZ)), and BizyAir now supports over 10 new base models. They all support ControlNet, LoRA, and IPAdapter. [BizyAir KSampler](https://siliconflow.github.io/BizyAir/ksampler/introduce.html) - [2024/07/31] 🌩️ The super-resolution node has been released, capable of enlarging images four times their original size. [BizyAir Photorealistic Image Super Resolution](https://siliconflow.github.io/BizyAir/others/index.html#bizyair-photorealistic-image-super-resolution) - [2024/07/25] 🌩️ Users can load BizyAir workflow examples directly by clicking the "☁️BizyAir Workflow Examples" button. [Example GIF](./docs/docs/getting-started/imgs/run-bizyair-examples.gif) -- [2024/07/23] 🌩️ [BizyAir ChatGLM3 Text Encode](./examples/bizyair_showcase_run_with_local_nodes.json) node is released. +- [2024/07/23] 🌩️ BizyAir ChatGLM3 Text Encode node is released. - [2024/07/16] 🌩️ [BizyAir Controlnet Union SDXL 1.0](https://siliconflow.github.io/BizyAir/controlnet-union/introduce.html) node is released. - [2024/07/14] 🌩️ We release Image Caption nodes and add a tutorial for utilizing the LLM node. [AI Assistant](https://siliconflow.github.io/BizyAir/ai-assistants/introduce.html) - [2024/07/11] 🌩️ We release new nodes that can perform ControlNet preprocessing. [BizyAir Controlnet Auxiliary Preprocessors](https://siliconflow.github.io/BizyAir/controlnet-preprocessor/introduce.html) - [2024/07/11] 🌩️ We release new nodes, featuring removing image background, photo-quality image generation, and animation super-resolution capabilities. -- [2024/07/10] 🌩️ We release nodes that support Kolors and LLM(large language models). [Kolors](https://siliconflow.github.io/BizyAir/kolors/introduce.html) +- [2024/07/10] 🌩️ We release nodes that support Kolors and LLM(large language models). BizyAir is a collection of [ComfyUI](https://github.com/comfyanonymous/ComfyUI) nodes that help you overcome environmental and hardware limitations, allowing you to more easily generate high-quality content with ComfyUI. diff --git a/__init__.py b/__init__.py index 68ab77b3..5d787e67 100644 --- a/__init__.py +++ b/__init__.py @@ -16,10 +16,6 @@ from . import auth -NODE_CLASS_MAPPINGS.update(**auth.NODE_CLASS_MAPPINGS) -NODE_DISPLAY_NAME_MAPPINGS.update(**auth.NODE_DISPLAY_NAME_MAPPINGS) - - from . import supernode NODE_CLASS_MAPPINGS.update(**supernode.NODE_CLASS_MAPPINGS) @@ -35,11 +31,6 @@ NODE_CLASS_MAPPINGS.update(**nodes_controlnet_aux.NODE_CLASS_MAPPINGS) NODE_DISPLAY_NAME_MAPPINGS.update(**nodes_controlnet_aux.NODE_DISPLAY_NAME_MAPPINGS) -from . import kolors - -NODE_CLASS_MAPPINGS.update(**kolors.NODE_CLASS_MAPPINGS) -NODE_DISPLAY_NAME_MAPPINGS.update(**kolors.NODE_DISPLAY_NAME_MAPPINGS) - from . import nodes_controlnet_union_sdxl diff --git a/auth.py b/auth.py index cd54e325..fd44d947 100644 --- a/auth.py +++ b/auth.py @@ -164,34 +164,3 @@ async def get_api_key(request): ) except Exception as e: return web.Response(text="str(e)", status=500) - - -class SetAPIKey: - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "API_KEY": ("STRING", {"default": "YOUR_API_KEY"}), - } - } - - RETURN_TYPES = () - FUNCTION = "set_api_key" - - CATEGORY = "☁️BizyAir" - OUTPUT_NODE = True - - def set_api_key(self, API_KEY="YOUR_API_KEY"): - return {"ui": {"api_key": (API_KEY,)}, "result": ()} - - @classmethod - def IS_CHANGED(s, latent): - return uuid.uuid4().hex - - -NODE_CLASS_MAPPINGS = { - "BizyAirSetAPIKey": SetAPIKey, -} -NODE_DISPLAY_NAME_MAPPINGS = { - "BizyAirSetAPIKey": "☁️Set SiliconCloud API Key(deprecated)", -} diff --git a/docs/docs/ai-assistants/imgs/image-caption-redraw.png b/docs/docs/ai-assistants/imgs/image-caption-redraw.png deleted file mode 100644 index e95682b5..00000000 Binary files a/docs/docs/ai-assistants/imgs/image-caption-redraw.png and /dev/null differ diff --git a/docs/docs/ai-assistants/imgs/image-caption.png b/docs/docs/ai-assistants/imgs/image-caption.png deleted file mode 100644 index d102aaa0..00000000 Binary files a/docs/docs/ai-assistants/imgs/image-caption.png and /dev/null differ diff --git a/docs/docs/ai-assistants/introduce.md b/docs/docs/ai-assistants/introduce.md index 00b0ddab..9d02e8ba 100644 --- a/docs/docs/ai-assistants/introduce.md +++ b/docs/docs/ai-assistants/introduce.md @@ -11,12 +11,6 @@ This node offers five Large Langauge Models, including two completely free mode You also have the freedom to set other system prompts for specific tasks. -## ☁️BizyAir Image Caption +## ☁️BizyAir Joy Caption -The ☁️BizyAir Image Caption node is a powerful tool designed to automatically generate descriptive captions for images. - -![](./imgs/image-caption.png) - - It is generally very useful in the workflow of redrawing images. - - ![](./imgs/image-caption-redraw.png) \ No newline at end of file +The ☁️BizyAir Joy Caption node is a powerful tool designed to automatically generate descriptive captions for images, thanks to https://huggingface.co/spaces/fancyfeast/joy-caption-pre-alpha. \ No newline at end of file diff --git a/examples/bizyair_kolors_img2img_workflow.json b/examples/bizyair_kolors_img2img_workflow.json deleted file mode 100644 index 38dab72a..00000000 --- a/examples/bizyair_kolors_img2img_workflow.json +++ /dev/null @@ -1,281 +0,0 @@ -{ - "last_node_id": 21, - "last_link_id": 31, - "nodes": [ - { - "id": 19, - "type": "BizyAirKolorsVAEEncode", - "pos": [ - 836, - 99 - ], - "size": { - "0": 226.8000030517578, - "1": 26 - }, - "flags": {}, - "order": 2, - "mode": 0, - "inputs": [ - { - "name": "pixels", - "type": "IMAGE", - "link": 26 - } - ], - "outputs": [ - { - "name": "LATENT", - "type": "LATENT", - "links": [ - 28 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsVAEEncode" - } - }, - { - "id": 18, - "type": "BizyAirKolorsVAEDecode", - "pos": [ - 1064, - 93 - ], - "size": { - "0": 226.8000030517578, - "1": 26 - }, - "flags": {}, - "order": 4, - "mode": 0, - "inputs": [ - { - "name": "samples", - "type": "LATENT", - "link": 31 - } - ], - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 25 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsVAEDecode" - } - }, - { - "id": 17, - "type": "LoadImage", - "pos": [ - 546, - 97 - ], - "size": { - "0": 261.8788146972656, - "1": 356.6060791015625 - }, - "flags": {}, - "order": 0, - "mode": 0, - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 26 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "MASK", - "type": "MASK", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "LoadImage" - }, - "widgets_values": [ - "ComfyUI_temp_ppfei_00003_ (1).png", - "image" - ] - }, - { - "id": 3, - "type": "PreviewImage", - "pos": [ - 1186, - 178 - ], - "size": { - "0": 728.3642578125, - "1": 404.66302490234375 - }, - "flags": {}, - "order": 5, - "mode": 0, - "inputs": [ - { - "name": "images", - "type": "IMAGE", - "link": 25 - } - ], - "properties": { - "Node name for S&R": "PreviewImage" - } - }, - { - "id": 21, - "type": "BizyAirKolorsTextEncode", - "pos": [ - 554, - 508 - ], - "size": { - "0": 400, - "1": 200 - }, - "flags": {}, - "order": 1, - "mode": 0, - "outputs": [ - { - "name": "kolors_embeds", - "type": "KOLORS_EMBEDS", - "links": [ - 29 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsTextEncode" - }, - "widgets_values": [ - "cinematic photograph a cyborg girl", - "", - 1 - ] - }, - { - "id": 20, - "type": "BizyAirKolorsSampler", - "pos": [ - 837, - 180 - ], - "size": { - "0": 315, - "1": 246 - }, - "flags": {}, - "order": 3, - "mode": 0, - "inputs": [ - { - "name": "kolors_embeds", - "type": "KOLORS_EMBEDS", - "link": 29 - }, - { - "name": "latent", - "type": "LATENT", - "link": 28 - } - ], - "outputs": [ - { - "name": "latent", - "type": "LATENT", - "links": [ - 31 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsSampler" - }, - "widgets_values": [ - 1024, - 1024, - 1, - "fixed", - 25, - 5, - "EulerDiscreteScheduler", - 0.75 - ] - } - ], - "links": [ - [ - 25, - 18, - 0, - 3, - 0, - "IMAGE" - ], - [ - 26, - 17, - 0, - 19, - 0, - "IMAGE" - ], - [ - 28, - 19, - 0, - 20, - 1, - "LATENT" - ], - [ - 29, - 21, - 0, - 20, - 0, - "KOLORS_EMBEDS" - ], - [ - 31, - 20, - 0, - 18, - 0, - "LATENT" - ] - ], - "groups": [], - "config": {}, - "extra": { - "ds": { - "scale": 0.9090909090909091, - "offset": { - "0": 54.40091857910156, - "1": 197.60369873046875 - } - } - }, - "version": 0.4 -} \ No newline at end of file diff --git a/examples/bizyair_kolors_text2img_workflow.json b/examples/bizyair_kolors_text2img_workflow.json deleted file mode 100644 index 952486a9..00000000 --- a/examples/bizyair_kolors_text2img_workflow.json +++ /dev/null @@ -1,190 +0,0 @@ -{ - "last_node_id": 23, - "last_link_id": 35, - "nodes": [ - { - "id": 21, - "type": "BizyAirKolorsTextEncode", - "pos": [ - 603, - 528 - ], - "size": { - "0": 400, - "1": 200 - }, - "flags": {}, - "order": 0, - "mode": 0, - "outputs": [ - { - "name": "kolors_embeds", - "type": "KOLORS_EMBEDS", - "links": [ - 34 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsTextEncode" - }, - "widgets_values": [ - "illustration a girl|cinematic photograph a cyborg girl", - "", - 1 - ] - }, - { - "id": 18, - "type": "BizyAirKolorsVAEDecode", - "pos": [ - 1355, - 521 - ], - "size": { - "0": 210, - "1": 26 - }, - "flags": {}, - "order": 2, - "mode": 0, - "inputs": [ - { - "name": "samples", - "type": "LATENT", - "link": 35 - } - ], - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 33 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsVAEDecode" - } - }, - { - "id": 22, - "type": "PreviewImage", - "pos": [ - 1361, - 590 - ], - "size": [ - 494.3333740234375, - 280 - ], - "flags": {}, - "order": 3, - "mode": 0, - "inputs": [ - { - "name": "images", - "type": "IMAGE", - "link": 33 - } - ], - "properties": { - "Node name for S&R": "PreviewImage" - } - }, - { - "id": 23, - "type": "BizyAirKolorsSampler", - "pos": [ - 1024, - 517 - ], - "size": { - "0": 315, - "1": 246 - }, - "flags": {}, - "order": 1, - "mode": 0, - "inputs": [ - { - "name": "kolors_embeds", - "type": "KOLORS_EMBEDS", - "link": 34 - }, - { - "name": "latent", - "type": "LATENT", - "link": null - } - ], - "outputs": [ - { - "name": "latent", - "type": "LATENT", - "links": [ - 35 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsSampler" - }, - "widgets_values": [ - 1024, - 1024, - 636619711728741, - "fixed", - 25, - 5, - "EulerDiscreteScheduler", - 1 - ] - } - ], - "links": [ - [ - 33, - 18, - 0, - 22, - 0, - "IMAGE" - ], - [ - 34, - 21, - 0, - 23, - 0, - "KOLORS_EMBEDS" - ], - [ - 35, - 23, - 0, - 18, - 0, - "LATENT" - ] - ], - "groups": [], - "config": {}, - "extra": { - "ds": { - "scale": 1, - "offset": { - "0": 0, - "1": 0 - } - } - }, - "version": 0.4 -} \ No newline at end of file diff --git a/examples/bizyair_showcase_run_with_local_nodes.json b/examples/bizyair_showcase_run_with_local_nodes.json deleted file mode 100644 index d2978d97..00000000 --- a/examples/bizyair_showcase_run_with_local_nodes.json +++ /dev/null @@ -1,352 +0,0 @@ -{ - "last_node_id": 49, - "last_link_id": 73, - "nodes": [ - { - "id": 20, - "type": "MZ_KolorsUNETLoaderV2", - "pos": [ - 1180, - 292 - ], - "size": { - "0": 320, - "1": 195 - }, - "flags": {}, - "order": 0, - "mode": 0, - "outputs": [ - { - "name": "model", - "type": "MODEL", - "links": [ - 68 - ], - "shape": 3, - "label": "model", - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "MZ_KolorsUNETLoaderV2" - }, - "widgets_values": [ - "diffusion_pytorch_model.fp16.safetensors" - ] - }, - { - "id": 5, - "type": "KSampler", - "pos": [ - 1187, - 535 - ], - "size": [ - 304.78125, - 262 - ], - "flags": {}, - "order": 5, - "mode": 0, - "inputs": [ - { - "name": "model", - "type": "MODEL", - "link": 68, - "label": "模型", - "slot_index": 0 - }, - { - "name": "positive", - "type": "CONDITIONING", - "link": 71, - "label": "正面条件" - }, - { - "name": "negative", - "type": "CONDITIONING", - "link": 73, - "label": "负面条件" - }, - { - "name": "latent_image", - "type": "LATENT", - "link": 6, - "label": "Latent", - "slot_index": 3 - } - ], - "outputs": [ - { - "name": "LATENT", - "type": "LATENT", - "links": [ - 69 - ], - "shape": 3, - "label": "Latent", - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "KSampler" - }, - "widgets_values": [ - 489730244656263, - "fixed", - 20, - 4.5, - "dpmpp_2m_sde_gpu", - "karras", - 1 - ] - }, - { - "id": 45, - "type": "BizyAirKolorsVAEDecode", - "pos": [ - 774, - 753 - ], - "size": [ - 383.51953125, - 27.515625 - ], - "flags": {}, - "order": 6, - "mode": 0, - "inputs": [ - { - "name": "samples", - "type": "LATENT", - "link": 69, - "slot_index": 0 - } - ], - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 70 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirKolorsVAEDecode" - } - }, - { - "id": 46, - "type": "BizyAirMZChatGLM3TextEncode", - "pos": [ - 763, - 291 - ], - "size": [ - 398.05859375, - 99.9296875 - ], - "flags": {}, - "order": 1, - "mode": 0, - "outputs": [ - { - "name": "CONDITIONING", - "type": "CONDITIONING", - "links": [ - 71 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirMZChatGLM3TextEncode" - }, - "widgets_values": [ - "真实的照片,20岁女生,红色外套,城市夜景" - ] - }, - { - "id": 48, - "type": "BizyAirMZChatGLM3TextEncode", - "pos": [ - 765, - 430 - ], - "size": { - "0": 398.05859375, - "1": 99.9296875 - }, - "flags": {}, - "order": 2, - "mode": 0, - "outputs": [ - { - "name": "CONDITIONING", - "type": "CONDITIONING", - "links": [ - 73 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "BizyAirMZChatGLM3TextEncode" - }, - "widgets_values": [ - "text, watermark" - ] - }, - { - "id": 7, - "type": "EmptyLatentImage", - "pos": [ - 771, - 591 - ], - "size": [ - 384.95703125, - 106 - ], - "flags": {}, - "order": 3, - "mode": 0, - "outputs": [ - { - "name": "LATENT", - "type": "LATENT", - "links": [ - 6 - ], - "shape": 3, - "label": "Latent" - } - ], - "properties": { - "Node name for S&R": "EmptyLatentImage" - }, - "widgets_values": [ - 768, - 1024, - 1 - ] - }, - { - "id": 11, - "type": "PreviewImage", - "pos": [ - 1518, - 300 - ], - "size": [ - 361.82421875, - 494.51953125 - ], - "flags": {}, - "order": 7, - "mode": 0, - "inputs": [ - { - "name": "images", - "type": "IMAGE", - "link": 70, - "label": "图像" - } - ], - "properties": { - "Node name for S&R": "PreviewImage" - } - }, - { - "id": 49, - "type": "Note", - "pos": [ - 463.5859375, - 283.58984375 - ], - "size": [ - 289.96484375, - 492.13671875 - ], - "flags": {}, - "order": 4, - "mode": 0, - "properties": { - "text": "" - }, - "widgets_values": [ - "BizyAir Nodes 可以与其他的 ComfyUI Nodes 混合运行的。\n在这个例子中,文本编码和 VAE 解码都使用的是 BizyAir 的节点。KSampler 使用的是本地的节点。" - ], - "color": "#432", - "bgcolor": "#653" - } - ], - "links": [ - [ - 6, - 7, - 0, - 5, - 3, - "LATENT" - ], - [ - 68, - 20, - 0, - 5, - 0, - "MODEL" - ], - [ - 69, - 5, - 0, - 45, - 0, - "LATENT" - ], - [ - 70, - 45, - 0, - 11, - 0, - "IMAGE" - ], - [ - 71, - 46, - 0, - 5, - 1, - "CONDITIONING" - ], - [ - 73, - 48, - 0, - 5, - 2, - "CONDITIONING" - ] - ], - "groups": [], - "config": {}, - "extra": { - "ds": { - "scale": 0.9090909090909092, - "offset": [ - 273.6350059140624, - 67.35037715624962 - ] - } - }, - "version": 0.4 -} \ No newline at end of file diff --git a/js/deprecated.js b/js/deprecated.js index 90a92d5c..6e72561f 100644 --- a/js/deprecated.js +++ b/js/deprecated.js @@ -6,13 +6,7 @@ app.registerExtension({ async beforeRegisterNodeDef(nodeType, nodeData, app) { const warning_msg = { - "BizyAirSetAPIKey": "It will be available until 2024/08/15. Please click \"BizyAir Key\" button to set API key instead.", - "BizyAirMZChatGLM3TextEncode": "It will be available until 2024/08/15. Please use \"☁️BizyAir MinusZone ChatGLM3 Text Encode\" node instead.", - "BizyAirKolorsTextEncode": "It will be available until 2024/08/15. Please use \"☁️BizyAir MinusZone ChatGLM3 Text Encode\" node instead.", - "BizyAirKolorsVAEEncode": "It will be available until 2024/08/15. Please use \"☁️BizyAir VAE Encode\" node instead.", - "BizyAirKolorsVAEDecode": "It will be available until 2024/08/15. Please use \"☁️BizyAir VAE Decode\" node instead.", - "BizyAirKolorsSampler": "It will be available until 2024/08/15. Please use \"☁️BizyAir KSampler\" node instead.", - //"BizyAirSuperResolution": "It will be available until 2024/08/31. Please use \"☁️BizyAir Image Super Resolution\" node instead.", + "BizyAirImageCaption": "It will be available until 2024/08/18. Please use \"☁️BizyAir Joy Caption\" node instead.", } if (Object.keys(warning_msg).includes(nodeData.name)) { async function alert_deprecated(node_name, display_name) { diff --git a/js/set_api_key.js b/js/set_api_key.js index 3604edd9..09ea2e43 100644 --- a/js/set_api_key.js +++ b/js/set_api_key.js @@ -37,14 +37,7 @@ app.registerExtension({ }; menu.append(BizyAir_SetAPIKey); - } -}); - - -app.registerExtension({ - name: "bizyair.set.api.key", - async setup() { const response = await api.fetchApi("/bizyair/get_api_key", { method: "GET" }); if (response.status === 200) { @@ -56,39 +49,5 @@ or you can only use nodes locally.`); const text = await response.text(); console.log("not set api key:", text) } - - }, - async beforeRegisterNodeDef(nodeType, nodeData, app) { - if (nodeData.name === "BizyAirSetAPIKey") { - async function set_api_key_to_cookies(text) { - if (text === "sk-****************") { - return; - } - const body = new FormData(); - body.append("api_key", text); - const response = await api.fetchApi("/bizyair/set_api_key", - { - method: "POST", - body: body, - } - ); - - if (response.status === 200) { - console.log("set SiliconCloud api key successfuly") - } else { - const text = await response.text(); - alert(`Please click "BizyAir Key" button to set API key first, - you can get your key from cloud.siliconflow.cn, - or you can only use nodes locally.`); - } - - this.widgets[0].value = "sk-****************"; - } - const onExecuted = nodeType.prototype.onExecuted; - nodeType.prototype.onExecuted = function (message) { - onExecuted?.apply(this, arguments); - set_api_key_to_cookies.call(this, message.api_key[0]); - }; - } - }, + } }); diff --git a/kolors.py b/kolors.py deleted file mode 100644 index df9fdd71..00000000 --- a/kolors.py +++ /dev/null @@ -1,295 +0,0 @@ -import copy -import os - - -import numpy as np -import torch - - -from .utils import ( - decode_and_deserialize, - send_post_request, - serialize_and_encode, - get_api_key, -) - -BIZYAIR_SERVER_ADDRESS = os.getenv( - "BIZYAIR_SERVER_ADDRESS", "https://api.siliconflow.cn" -) - - -class BizyAirKolorsTextEncode: - API_URL = f"{BIZYAIR_SERVER_ADDRESS}/supernode/kolorschatglmv2" - - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "prompt": ( - "STRING", - { - "multiline": True, - "default": "", - }, - ), - "negative_prompt": ( - "STRING", - { - "multiline": True, - "default": "", - }, - ), - "num_images_per_prompt": ( - "INT", - {"default": 1, "min": 1, "max": 4, "step": 1}, - ), - }, - } - - RETURN_TYPES = ("KOLORS_EMBEDS",) - RETURN_NAMES = ("kolors_embeds",) - FUNCTION = "encode" - CATEGORY = "☁️BizyAir/Kolors" - - def encode(self, prompt, negative_prompt, num_images_per_prompt): - API_KEY = get_api_key() - split_pos_text = prompt.split("|") - num_prompts = len(split_pos_text) - assert ( - num_prompts * num_images_per_prompt <= 4 - ), f"The num_prompts*num_images_per_prompt should be less than or equal 4, got {num_prompts}x{num_images_per_prompt}={num_prompts*num_images_per_prompt}, try to reduce the '|' or num_images_per_prompt" - - payload = { - "positive_prompt": prompt, - "negative_prompt": negative_prompt, - "num_images_per_prompt": num_images_per_prompt, - } - auth = f"Bearer {API_KEY}" - headers = { - "accept": "application/json", - "content-type": "application/json", - "authorization": auth, - } - - response: str = send_post_request( - self.API_URL, payload=payload, headers=headers - ) - kolors_embeds = decode_and_deserialize(response) - for k, v in kolors_embeds.items(): - kolors_embeds[k] = torch.from_numpy(v) - return (kolors_embeds,) - - -class BizyAirKolorsVAEEncode: - API_URL = f"{BIZYAIR_SERVER_ADDRESS}/supernode/kolorsvaeencode" - - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "pixels": ("IMAGE",), - } - } - - RETURN_TYPES = ("LATENT",) - FUNCTION = "encode" - - CATEGORY = "☁️BizyAir/Kolors" - - def encode(self, pixels): - API_KEY = get_api_key() - device = pixels.device - payload = { - "images": None, - "is_compress": True, - } - auth = f"Bearer {API_KEY}" - headers = { - "accept": "application/json", - "content-type": "application/json", - "authorization": auth, - } - np_pixels = copy.deepcopy(pixels) - np_pixels = np_pixels.cpu().detach().numpy() - images, compress = serialize_and_encode(np_pixels, compress=True) - payload["images"] = images - payload["is_compress"] = compress - response: str = send_post_request( - self.API_URL, payload=payload, headers=headers - ) - samples = decode_and_deserialize(response) - for k, v in samples.items(): - samples[k] = torch.from_numpy(v) - samples[k] = samples[k].to(device=device) - print("yaochi debug, what you pass is ", type(samples)) - return (samples,) - - -class BizyAirKolorsVAEDecode: - API_URL = f"{BIZYAIR_SERVER_ADDRESS}/supernode/kolorsvaedecode" - - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "samples": ("LATENT",), - } - } - - RETURN_TYPES = ("IMAGE",) - FUNCTION = "decode" - - CATEGORY = "☁️BizyAir/Kolors" - - def decode(self, samples): - API_KEY = get_api_key() - - payload = { - "samples": None, - "is_compress": True, - } - auth = f"Bearer {API_KEY}" - headers = { - "accept": "application/json", - "content-type": "application/json", - "authorization": auth, - } - for k, v in samples.items(): - if hasattr(v, "cpu"): - samples[k] = v.cpu().detach().numpy() - input_samples, compress = serialize_and_encode(samples, compress=True) - payload["samples"] = input_samples - - response: str = send_post_request( - self.API_URL, payload=payload, headers=headers - ) - images = decode_and_deserialize(response) - return (images,) - - -class BizyAirKolorsSampler: - API_URL = f"{BIZYAIR_SERVER_ADDRESS}/supernode/kolorssamplerv2" - - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "kolors_embeds": ("KOLORS_EMBEDS",), - "width": ("INT", {"default": 1024, "min": 64, "max": 1536, "step": 64}), - "height": ( - "INT", - {"default": 1024, "min": 64, "max": 1536, "step": 64}, - ), - "seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}), - "steps": ("INT", {"default": 25, "min": 1, "max": 35, "step": 1}), - "cfg": ( - "FLOAT", - {"default": 5.0, "min": 0.0, "max": 20.0, "step": 0.01}, - ), - "scheduler": ( - [ - "EulerDiscreteScheduler", - "EulerAncestralDiscreteScheduler", - "DPMSolverMultistepScheduler", - "DPMSolverMultistepScheduler_SDE_karras", - "UniPCMultistepScheduler", - "DEISMultistepScheduler", - ], - {"default": "EulerDiscreteScheduler"}, - ), - }, - "optional": { - "latent": ("LATENT",), - "denoise_strength": ( - "FLOAT", - {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, - ), - }, - } - - RETURN_TYPES = ("LATENT",) - RETURN_NAMES = ("latent",) - FUNCTION = "process" - CATEGORY = "☁️BizyAir/Kolors" - - def process( - self, - kolors_embeds, - width, - height, - seed, - steps, - cfg, - scheduler, - latent=None, - denoise_strength=1.0, - ): - API_KEY = get_api_key() - device = None - for _, v in kolors_embeds.items(): - device = v.device - break - API_KEY = get_api_key() - - payload = { - "width": width, - "height": height, - "seed": seed, - "steps": steps, - "cfg": cfg, - "scheduler": scheduler, - "denoise_strength": denoise_strength, - "inputs": None, - "is_compress": True, - } - if latent is not None: - assert ( - latent["samples"].shape[0] == kolors_embeds["prompt_embeds"].shape[0] - ), f"The batch size of latent samples should be the same as the prompt_embeds, got {latent['samples'].shape[0]} and {kolors_embeds['prompt_embeds'].shape[0]}" - - # convert the tensors to numpy array - np_kolors_embeds = copy.deepcopy(kolors_embeds) - np_latent = copy.deepcopy(latent) if latent is not None else None - for k, v in np_kolors_embeds.items(): - if hasattr(v, "cpu"): - np_kolors_embeds[k] = v.cpu().detach().numpy() - if np_latent is not None: - for k, v in latent.items(): - if hasattr(v, "cpu"): - np_latent[k] = v.cpu().detach().numpy() - - inputs_dict, is_compress = serialize_and_encode( - {"kolors_embeddings": np_kolors_embeds, "latent": np_latent}, compress=True - ) - - payload["inputs"] = inputs_dict - payload["is_compress"] = is_compress - auth = f"Bearer {API_KEY}" - headers = { - "accept": "application/json", - "content-type": "application/json", - "authorization": auth, - } - - response: str = send_post_request( - self.API_URL, payload=payload, headers=headers - ) - latent_out = decode_and_deserialize(response) - for k, v in latent_out.items(): - latent_out[k] = torch.from_numpy(v).to(device=device) - - return (latent_out,) - - -NODE_CLASS_MAPPINGS = { - "BizyAirKolorsTextEncode": BizyAirKolorsTextEncode, - "BizyAirKolorsVAEEncode": BizyAirKolorsVAEEncode, - "BizyAirKolorsVAEDecode": BizyAirKolorsVAEDecode, - "BizyAirKolorsSampler": BizyAirKolorsSampler, -} -NODE_DISPLAY_NAME_MAPPINGS = { - "BizyAirKolorsTextEncode": "☁️BizyAir KolorsTextEncode(deprecated)", - "BizyAirKolorsVAEEncode": "☁️BizyAir Kolors VAE Encode(deprecated)", - "BizyAirKolorsVAEDecode": "☁️BizyAir Kolors VAE Decode(deprecated)", - "BizyAirKolorsSampler": "☁️BizyAir KolorsSampler(deprecated)", -} diff --git a/mzkolors.py b/mzkolors.py index 3644ab91..fac1b396 100644 --- a/mzkolors.py +++ b/mzkolors.py @@ -87,10 +87,8 @@ def mz_encode(self, text): NODE_CLASS_MAPPINGS = { - "BizyAirMZChatGLM3TextEncode": BizyAirMZChatGLM3TextEncode, "BizyAir_MinusZoneChatGLM3TextEncode": BizyAir_MinusZoneChatGLM3TextEncode, } NODE_DISPLAY_NAME_MAPPINGS = { - "BizyAirMZChatGLM3TextEncode": "☁️BizyAir ChatGLM3 Text Encode(deprecated)", "BizyAir_MinusZoneChatGLM3TextEncode": "☁️BizyAir MinusZone ChatGLM3 Text Encode", } diff --git a/src/bizyair/client.py b/src/bizyair/client.py index 145216b4..6aac0eaa 100644 --- a/src/bizyair/client.py +++ b/src/bizyair/client.py @@ -13,7 +13,7 @@ def __init__(self, api_url, api_key: str = None): def get_headers(self, sse=False): if self.API_KEY is None or not self.API_KEY.startswith("sk-"): raise ValueError( - f"API key is not set. Please provide a valid API key, {self.API_KEY=}" + f"API key is not set. Please provide a valid API key(from cloud.siliconflow.cn), {self.API_KEY=}" ) headers = { diff --git a/src/bizyair/image_utils.py b/src/bizyair/image_utils.py index d8e34c18..b5909c3f 100644 --- a/src/bizyair/image_utils.py +++ b/src/bizyair/image_utils.py @@ -165,7 +165,7 @@ def update_nodes_from_others(self, *others): def get_headers(self): if self.API_KEY is None or not self.API_KEY.startswith("sk-"): raise ValueError( - f"API key is not set. Please provide a valid API key, {self.API_KEY=}" + f"API key is not set. Please provide a valid API key(from cloud.siliconflow.cn), {self.API_KEY=}" ) return {