bizyengine 1.2.51__py3-none-any.whl → 1.2.52__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,7 @@ from .nodes_nunchaku import *
21
21
  from .nodes_reactor import *
22
22
  from .nodes_sam2 import *
23
23
  from .nodes_sd3 import *
24
+ from .nodes_seedream import *
24
25
  from .nodes_segment_anything import *
25
26
  from .nodes_testing_utils import *
26
27
  from .nodes_trellis import *
@@ -0,0 +1,195 @@
1
+ import base64
2
+ import io
3
+ import json
4
+ import logging
5
+ import re
6
+ from pathlib import Path
7
+
8
+ import requests
9
+ import torch
10
+ from comfy_api_nodes.apinode_utils import (
11
+ bytesio_to_image_tensor,
12
+ tensor_to_base64_string,
13
+ )
14
+
15
+ from bizyengine.core import BizyAirBaseNode, pop_api_key_and_prompt_id
16
+ from bizyengine.core.common import client
17
+ from bizyengine.core.common.env_var import BIZYAIR_SERVER_ADDRESS
18
+
19
+
20
+ def download_png(url: str) -> bytes:
21
+ """下载 PNG 图片"""
22
+ resp = requests.get(url, stream=True, timeout=30)
23
+ resp.raise_for_status() # 非 2xx 会抛异常
24
+ return resp.content
25
+
26
+
27
+ class Seedream4(BizyAirBaseNode):
28
+ def __init__(self):
29
+ pass
30
+
31
+ @classmethod
32
+ def INPUT_TYPES(s):
33
+ return {
34
+ "required": {
35
+ "prompt": (
36
+ "STRING",
37
+ {
38
+ "multiline": True,
39
+ "default": "",
40
+ },
41
+ ),
42
+ "size": (
43
+ [
44
+ "1K Square (1024x1024)",
45
+ "2K Square (2048x2048)",
46
+ "4K Square (4096x4096)",
47
+ "HD 16:9 (1920x1080)",
48
+ "2K 16:9 (2560x1440)",
49
+ "4K 16:9 (3840x2160)",
50
+ "Portrait 9:16 (1080x1920)",
51
+ "Portrait 3:4 (1536x2048)",
52
+ "Landscape 4:3 (2048x1536)",
53
+ "Ultra-wide 21:9 (3440x1440)",
54
+ "Custom",
55
+ ],
56
+ {
57
+ "default": "HD 16:9 (1920x1080)",
58
+ },
59
+ ),
60
+ "custom_width": ("INT", {"default": 1920, "min": 1024, "max": 4096}),
61
+ "custom_height": ("INT", {"default": 1080, "min": 1024, "max": 4096}),
62
+ "model": (
63
+ ["doubao-seedream-4-0-250828"],
64
+ {"default": "doubao-seedream-4-0-250828"},
65
+ ),
66
+ },
67
+ "optional": {
68
+ "image": ("IMAGE",),
69
+ "image2": ("IMAGE",),
70
+ "image3": ("IMAGE",),
71
+ "image4": ("IMAGE",),
72
+ "image5": ("IMAGE",),
73
+ "image6": ("IMAGE",),
74
+ "image7": ("IMAGE",),
75
+ "image8": ("IMAGE",),
76
+ "image9": ("IMAGE",),
77
+ "image10": ("IMAGE",),
78
+ },
79
+ }
80
+
81
+ RETURN_TYPES = ("IMAGE",)
82
+ FUNCTION = "execute"
83
+ OUTPUT_NODE = False
84
+ CATEGORY = "☁️BizyAir/External APIs/Doubao"
85
+
86
+ def execute(self, **kwargs):
87
+ try:
88
+ model = kwargs.get("model", "doubao-seedream-4-0-250828")
89
+ url = f"{BIZYAIR_SERVER_ADDRESS}/proxy_inference/Doubao/{model}"
90
+ extra_data = pop_api_key_and_prompt_id(kwargs)
91
+
92
+ prompt = kwargs.get("prompt", "")
93
+ size = kwargs.get("size", "1K Square (1024x1024)")
94
+
95
+ match size:
96
+ case "1K Square (1024x1024)":
97
+ width = 1024
98
+ height = 1024
99
+ case "2K Square (2048x2048)":
100
+ width = 2048
101
+ height = 2048
102
+ case "4K Square (4096x4096)":
103
+ width = 4096
104
+ height = 4096
105
+ case "HD 16:9 (1920x1080)":
106
+ width = 1920
107
+ height = 1080
108
+ case "2K 16:9 (2560x1440)":
109
+ width = 2560
110
+ height = 1440
111
+ case "4K 16:9 (3840x2160)":
112
+ width = 3840
113
+ height = 2160
114
+ case "Portrait 9:16 (1080x1920)":
115
+ width = 1080
116
+ height = 1920
117
+ case "Portrait 3:4 (1536x2048)":
118
+ width = 1536
119
+ height = 2048
120
+ case "Landscape 4:3 (2048x1536)":
121
+ width = 2048
122
+ height = 1536
123
+ case "Ultra-wide 21:9 (3440x1440)":
124
+ width = 3440
125
+ height = 1440
126
+ case "Custom":
127
+ width = kwargs.get("custom_width", 1920)
128
+ height = kwargs.get("custom_height", 1080)
129
+
130
+ case _:
131
+ raise ValueError(f"Invalid size: {size}")
132
+
133
+ sizeStr = f"{width}x{height}"
134
+
135
+ images = []
136
+ total_size = 0
137
+ for _, img in enumerate(
138
+ [
139
+ kwargs.get("image", None),
140
+ kwargs.get("image2", None),
141
+ kwargs.get("image3", None),
142
+ kwargs.get("image4", None),
143
+ kwargs.get("image5", None),
144
+ kwargs.get("image6", None),
145
+ kwargs.get("image7", None),
146
+ kwargs.get("image8", None),
147
+ kwargs.get("image9", None),
148
+ kwargs.get("image10", None),
149
+ ],
150
+ 1,
151
+ ):
152
+ if img is not None:
153
+ # 都当作PNG就行
154
+ b64_data = tensor_to_base64_string(img)
155
+ if len(b64_data) > 10 * 1024 * 1024:
156
+ raise ValueError(
157
+ "Image size is too large, Seedream 4.0 only supports up to 10MB"
158
+ )
159
+ images.append(f"data:image/png;base64,{b64_data}")
160
+ total_size += len(b64_data)
161
+ if total_size > 50 * 1024 * 1024:
162
+ raise ValueError(
163
+ "Total size of images is too large, BizyAir only supports up to 50MB"
164
+ )
165
+
166
+ data = {
167
+ "prompt": prompt,
168
+ "size": sizeStr,
169
+ "image": images,
170
+ "model": model,
171
+ "watermark": False,
172
+ "response_format": "url",
173
+ }
174
+
175
+ json_payload = json.dumps(data).encode("utf-8")
176
+ headers = client.headers(api_key=extra_data["api_key"])
177
+ headers["X-BIZYAIR-PROMPT-ID"] = extra_data["prompt_id"]
178
+ resp = client.send_request(
179
+ url=url,
180
+ data=json_payload,
181
+ headers=headers,
182
+ )
183
+
184
+ # 结果会包含图片URL,客户端这里负责下载
185
+ if not "data" in resp:
186
+ raise ValueError(f"Invalid response: {resp}")
187
+ if not "url" in resp["data"][0]:
188
+ raise ValueError(f"Invalid response: {resp}")
189
+
190
+ image_data = download_png(resp["data"][0]["url"])
191
+ return (bytesio_to_image_tensor(io.BytesIO(image_data)),)
192
+
193
+ except Exception as e:
194
+ logging.error(f"Seedream 4.0 API error: {e}")
195
+ raise e
bizyengine/version.txt CHANGED
@@ -1 +1 @@
1
- 1.2.51
1
+ 1.2.52
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bizyengine
3
- Version: 1.2.51
3
+ Version: 1.2.52
4
4
  Summary: [a/BizyAir](https://github.com/siliconflow/BizyAir) Comfy Nodes that can run in any environment.
5
5
  Author-email: SiliconFlow <yaochi@siliconflow.cn>
6
6
  Project-URL: Repository, https://github.com/siliconflow/BizyAir
@@ -1,5 +1,5 @@
1
1
  bizyengine/__init__.py,sha256=GP9V-JM07fz7uv_qTB43QEA2rKdrVJxi5I7LRnn_3ZQ,914
2
- bizyengine/version.txt,sha256=AvxtajeVm2SVm3pKmMIouv9qTZ-GSKH6a35TmY6KQVo,7
2
+ bizyengine/version.txt,sha256=IjisjQCOb46a60B43ZZzkG9k1UlLoV_j4Wz2PTTdMbM,7
3
3
  bizyengine/bizy_server/__init__.py,sha256=SP9oSblnPo4KQyh7yOGD26YCskFAcQHAZy04nQBNRIw,200
4
4
  bizyengine/bizy_server/api_client.py,sha256=Z7G5IjaEqSJkF6nLLw2R3bpgBAOi5ClQiUbel6NMXmE,43932
5
5
  bizyengine/bizy_server/errno.py,sha256=RIyvegX3lzpx_1L1q2XVvu3on0kvYgKiUQ8U3ZtyF68,16823
@@ -10,7 +10,7 @@ bizyengine/bizy_server/resp.py,sha256=iOFT5Ud7VJBP2uqkojJIgc3y2ifMjjEXoj0ewneL9l
10
10
  bizyengine/bizy_server/server.py,sha256=isOzHDk2kD6WjdlemeOA7j_xLnZ2vat_NvE1I0bsOFw,57490
11
11
  bizyengine/bizy_server/stream_response.py,sha256=H2XHqlVRtQMhgdztAuG7l8-iV_Pm42u2x6WJ0gNVIW0,9654
12
12
  bizyengine/bizy_server/utils.py,sha256=Kkn-AATZcdaDhg8Rg_EJW6aKqkyiSE2EYmuyOhUwXso,3863
13
- bizyengine/bizyair_extras/__init__.py,sha256=lsGuqMnFX-WSOUszSQ5NB6FnKcHlhhO1WG9iiywWQug,1092
13
+ bizyengine/bizyair_extras/__init__.py,sha256=kZ8LQIcdc5mHqqLCrqJi0flIbDr9PtCX0C6TX8El6QQ,1122
14
14
  bizyengine/bizyair_extras/nodes_advanced_refluxcontrol.py,sha256=cecfjrtnjJAty9aNkhz8BlmHUC1NImkFlUDiA0COEa4,2242
15
15
  bizyengine/bizyair_extras/nodes_cogview4.py,sha256=Ni0TDOycczyDhYPvSR68TxGV_wE2uhaxd8MIj-J4-3o,2031
16
16
  bizyengine/bizyair_extras/nodes_comfyui_detail_daemon.py,sha256=i71it24tiGvZ3h-XFWISr4CpZszUtPuz3UrZARYluLk,6169
@@ -32,6 +32,7 @@ bizyengine/bizyair_extras/nodes_nunchaku.py,sha256=iI1Qe_5fQ_43QdUS_reCIOyRFv9-B
32
32
  bizyengine/bizyair_extras/nodes_reactor.py,sha256=hbm0HGQWAr_qMcWjp0nMZMtF4mUjTfPw8yK1rq1miAI,8157
33
33
  bizyengine/bizyair_extras/nodes_sam2.py,sha256=JTrB7ELwhw6_uOjykRWK9KyOqpYoOtJiGKMxFUbHnNQ,10554
34
34
  bizyengine/bizyair_extras/nodes_sd3.py,sha256=lZCxj0IFmuxk1fZTDcRKgVV5QWHjkUdpR4w9-DZbMf4,1727
35
+ bizyengine/bizyair_extras/nodes_seedream.py,sha256=-I22lrdR0S6oRCgN7e5HD8pOJhuGBxDMlhX2S-CyOhY,6855
35
36
  bizyengine/bizyair_extras/nodes_segment_anything.py,sha256=x1ei2UggHnB8T6aUtK_ZcUehMALEyLUnDoD5SNJCbFU,7249
36
37
  bizyengine/bizyair_extras/nodes_segment_anything_utils.py,sha256=ZefAqrFrevDH3XY_wipr_VwKfeXrgpZEUFaqg_JGOdU,4714
37
38
  bizyengine/bizyair_extras/nodes_testing_utils.py,sha256=lYmcyCIkTkQ7WOZfpEPU9wUbEvC_mL6_A46ks68WzZA,3988
@@ -91,7 +92,7 @@ bizyengine/misc/route_sam.py,sha256=-bMIR2QalfnszipGxSxvDAHGJa5gPSrjkYPb5baaRg4,
91
92
  bizyengine/misc/segment_anything.py,sha256=wNKYwlYPMszfwj23524geFZJjZaG4eye65SGaUnh77I,8941
92
93
  bizyengine/misc/supernode.py,sha256=STN9gaxfTSErH8OiHeZa47d8z-G9S0I7fXuJvHQOBFM,4532
93
94
  bizyengine/misc/utils.py,sha256=CKduySGSMNGlJMImHyZmN-giABY5VUaB88f6Kq-HAV0,6831
94
- bizyengine-1.2.51.dist-info/METADATA,sha256=ubIks74xsnM0PG1697BjTcGvw-LxY5gaG-btFI8-cUk,734
95
- bizyengine-1.2.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
96
- bizyengine-1.2.51.dist-info/top_level.txt,sha256=2zapzqxX-we5cRyJkGf9bd5JinRtXp3-_uDI-xCAnc0,11
97
- bizyengine-1.2.51.dist-info/RECORD,,
95
+ bizyengine-1.2.52.dist-info/METADATA,sha256=z4iUCltSLd23LQ2kawCWf1pCDyTqbu81DQNglRCb4AM,734
96
+ bizyengine-1.2.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
+ bizyengine-1.2.52.dist-info/top_level.txt,sha256=2zapzqxX-we5cRyJkGf9bd5JinRtXp3-_uDI-xCAnc0,11
98
+ bizyengine-1.2.52.dist-info/RECORD,,