bizyengine 1.2.48__py3-none-any.whl → 1.2.49__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.
- bizyengine/bizyair_extras/__init__.py +1 -0
- bizyengine/bizyair_extras/nodes_gemini.py +162 -0
- bizyengine/version.txt +1 -1
- {bizyengine-1.2.48.dist-info → bizyengine-1.2.49.dist-info}/METADATA +1 -1
- {bizyengine-1.2.48.dist-info → bizyengine-1.2.49.dist-info}/RECORD +7 -6
- {bizyengine-1.2.48.dist-info → bizyengine-1.2.49.dist-info}/WHEEL +0 -0
- {bizyengine-1.2.48.dist-info → bizyengine-1.2.49.dist-info}/top_level.txt +0 -0
|
@@ -9,6 +9,7 @@ from .nodes_custom_sampler import *
|
|
|
9
9
|
from .nodes_dataset import *
|
|
10
10
|
from .nodes_differential_diffusion import *
|
|
11
11
|
from .nodes_flux import *
|
|
12
|
+
from .nodes_gemini import *
|
|
12
13
|
from .nodes_hunyuan3d import *
|
|
13
14
|
from .nodes_image_utils import *
|
|
14
15
|
from .nodes_ip2p import *
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import io
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
import torch
|
|
8
|
+
from comfy_api_nodes.apinode_utils import tensor_to_base64_string
|
|
9
|
+
from PIL import Image, ImageOps
|
|
10
|
+
|
|
11
|
+
from bizyengine.core import BizyAirBaseNode, pop_api_key_and_prompt_id
|
|
12
|
+
from bizyengine.core.common import client
|
|
13
|
+
from bizyengine.core.common.env_var import BIZYAIR_SERVER_ADDRESS
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Tensor to PIL
|
|
17
|
+
def tensor_to_pil(image):
|
|
18
|
+
return Image.fromarray(
|
|
19
|
+
np.clip(255.0 * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def image_to_base64(pil_image, pnginfo=None):
|
|
24
|
+
# 创建一个BytesIO对象,用于临时存储图像数据
|
|
25
|
+
image_data = io.BytesIO()
|
|
26
|
+
|
|
27
|
+
# 将图像保存到BytesIO对象中,格式为PNG
|
|
28
|
+
pil_image.save(image_data, format="PNG", pnginfo=pnginfo)
|
|
29
|
+
|
|
30
|
+
# 将BytesIO对象的内容转换为字节串
|
|
31
|
+
image_data_bytes = image_data.getvalue()
|
|
32
|
+
|
|
33
|
+
# 将图像数据编码为Base64字符串
|
|
34
|
+
encoded_image = "data:image/png;base64," + base64.b64encode(
|
|
35
|
+
image_data_bytes
|
|
36
|
+
).decode("utf-8")
|
|
37
|
+
|
|
38
|
+
return encoded_image
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def base64_to_image(base64_string):
|
|
42
|
+
# 去除前缀
|
|
43
|
+
base64_list = base64_string.split(",", 1)
|
|
44
|
+
if len(base64_list) == 2:
|
|
45
|
+
prefix, base64_data = base64_list
|
|
46
|
+
else:
|
|
47
|
+
base64_data = base64_list[0]
|
|
48
|
+
|
|
49
|
+
# 从base64字符串中解码图像数据
|
|
50
|
+
image_data = base64.b64decode(base64_data)
|
|
51
|
+
|
|
52
|
+
# 创建一个内存流对象
|
|
53
|
+
image_stream = io.BytesIO(image_data)
|
|
54
|
+
|
|
55
|
+
# 使用PIL的Image模块打开图像数据
|
|
56
|
+
image = Image.open(image_stream)
|
|
57
|
+
|
|
58
|
+
return image
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class NanoBanana(BizyAirBaseNode):
|
|
62
|
+
def __init__(self):
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
@classmethod
|
|
66
|
+
def INPUT_TYPES(s):
|
|
67
|
+
return {
|
|
68
|
+
"required": {
|
|
69
|
+
"prompt": (
|
|
70
|
+
"STRING",
|
|
71
|
+
{
|
|
72
|
+
"multiline": True,
|
|
73
|
+
"default": "",
|
|
74
|
+
},
|
|
75
|
+
),
|
|
76
|
+
"temperature": (
|
|
77
|
+
"FLOAT",
|
|
78
|
+
{"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.05},
|
|
79
|
+
),
|
|
80
|
+
"top_p": (
|
|
81
|
+
"FLOAT",
|
|
82
|
+
{"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.05},
|
|
83
|
+
),
|
|
84
|
+
"seed": ("INT", {"default": 0, "min": 0, "max": 2147483647}),
|
|
85
|
+
"max_tokens": ("INT", {"default": 8192, "min": 1, "max": 8192}),
|
|
86
|
+
},
|
|
87
|
+
"optional": {
|
|
88
|
+
"image": ("IMAGE",),
|
|
89
|
+
"image2": ("IMAGE",),
|
|
90
|
+
"image3": ("IMAGE",),
|
|
91
|
+
"image4": ("IMAGE",),
|
|
92
|
+
"image5": ("IMAGE",),
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
RETURN_TYPES = ("IMAGE",)
|
|
97
|
+
FUNCTION = "execute"
|
|
98
|
+
OUTPUT_NODE = False
|
|
99
|
+
CATEGORY = "☁️BizyAir/External APIs/Gemini"
|
|
100
|
+
|
|
101
|
+
def execute(self, prompt, temperature, top_p, seed, max_tokens, **kwargs):
|
|
102
|
+
url = f"{BIZYAIR_SERVER_ADDRESS}/proxy_inference/VertexAI/gemini-2.5-flash-image-preview"
|
|
103
|
+
extra_data = pop_api_key_and_prompt_id(kwargs)
|
|
104
|
+
parts = [{"text": prompt}]
|
|
105
|
+
for _, img in enumerate(
|
|
106
|
+
[
|
|
107
|
+
kwargs.get("image", None),
|
|
108
|
+
kwargs.get("image2", None),
|
|
109
|
+
kwargs.get("image3", None),
|
|
110
|
+
kwargs.get("image4", None),
|
|
111
|
+
kwargs.get("image5", None),
|
|
112
|
+
],
|
|
113
|
+
1,
|
|
114
|
+
):
|
|
115
|
+
if img is not None:
|
|
116
|
+
parts.append(
|
|
117
|
+
{
|
|
118
|
+
"inline_data": {
|
|
119
|
+
"mime_type": "image/png",
|
|
120
|
+
"data": tensor_to_base64_string(img),
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
data = {
|
|
125
|
+
"contents": {
|
|
126
|
+
"parts": parts,
|
|
127
|
+
"role": "user",
|
|
128
|
+
},
|
|
129
|
+
"generationConfig": {
|
|
130
|
+
"seed": seed,
|
|
131
|
+
"responseModalities": ["TEXT", "IMAGE"],
|
|
132
|
+
"temperature": temperature,
|
|
133
|
+
"topP": top_p,
|
|
134
|
+
"maxOutputTokens": max_tokens,
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
json_payload = json.dumps(data).encode("utf-8")
|
|
138
|
+
headers = client.headers(api_key=extra_data["api_key"])
|
|
139
|
+
headers["X-BIZYAIR-PROMPT-ID"] = extra_data[
|
|
140
|
+
"prompt_id"
|
|
141
|
+
] # 额外参数vertexai会拒绝,所以用请求头传
|
|
142
|
+
resp = client.send_request(
|
|
143
|
+
url=url,
|
|
144
|
+
data=json_payload,
|
|
145
|
+
headers=headers,
|
|
146
|
+
)
|
|
147
|
+
# 解析base64图片
|
|
148
|
+
b64_data = None
|
|
149
|
+
for part in resp["candidates"][0]["content"]["parts"]:
|
|
150
|
+
if part.get("inlineData", None):
|
|
151
|
+
b64_data = part["inlineData"]["data"]
|
|
152
|
+
break
|
|
153
|
+
if b64_data:
|
|
154
|
+
i = base64_to_image(b64_data)
|
|
155
|
+
# 下面代码参考LoadImage
|
|
156
|
+
i = ImageOps.exif_transpose(i)
|
|
157
|
+
image = i.convert("RGB")
|
|
158
|
+
image = np.array(image).astype(np.float32) / 255.0
|
|
159
|
+
image = torch.from_numpy(image)[None,]
|
|
160
|
+
return (image,)
|
|
161
|
+
else:
|
|
162
|
+
raise ValueError("No image found in response")
|
bizyengine/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.
|
|
1
|
+
1.2.49
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bizyengine
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.49
|
|
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=
|
|
2
|
+
bizyengine/version.txt,sha256=AgBNjKfkdaaSpzlSp-niqT0eeAyzzEPm_pDtkPfEXLE,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=1UiFmE2U7r7hCHgsw4-p_YL0VCmTJc9NyYDEbhkanaY,16336
|
|
@@ -10,7 +10,7 @@ bizyengine/bizy_server/resp.py,sha256=iOFT5Ud7VJBP2uqkojJIgc3y2ifMjjEXoj0ewneL9l
|
|
|
10
10
|
bizyengine/bizy_server/server.py,sha256=7OWEA8GMrqpg4jxCvakX5zR2JukEOhKbqPRefYo6t8c,59707
|
|
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=
|
|
13
|
+
bizyengine/bizyair_extras/__init__.py,sha256=lsGuqMnFX-WSOUszSQ5NB6FnKcHlhhO1WG9iiywWQug,1092
|
|
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
|
|
@@ -22,6 +22,7 @@ bizyengine/bizyair_extras/nodes_custom_sampler.py,sha256=NK-7sdcp8oxJisjTEFfBskk
|
|
|
22
22
|
bizyengine/bizyair_extras/nodes_dataset.py,sha256=htF0YZb_FHncLhLDEbJfNCVqJ6rvlo1ZLk7iY42Rylc,3440
|
|
23
23
|
bizyengine/bizyair_extras/nodes_differential_diffusion.py,sha256=nSrbD-w0XtrwktwzME5M0Vmi1sI7Z08AqwgymTdThqo,370
|
|
24
24
|
bizyengine/bizyair_extras/nodes_flux.py,sha256=ls94kGBuBNgW5c6uhG36iZLk1TTM2TIoTTcpERgEE5E,2683
|
|
25
|
+
bizyengine/bizyair_extras/nodes_gemini.py,sha256=0Yh8NINFVkU3kh7PuYErhweO5id3SI3IXQORO4J1fNw,5076
|
|
25
26
|
bizyengine/bizyair_extras/nodes_hunyuan3d.py,sha256=dWHLeqX68N7zKnfDMzm9nutmCNtFT6-wwt7P5cPDu7Q,2058
|
|
26
27
|
bizyengine/bizyair_extras/nodes_image_utils.py,sha256=BldF_CKD2M01K8-SnG-QV86u3HZqFz_GP5GrCQ5CFDQ,2875
|
|
27
28
|
bizyengine/bizyair_extras/nodes_ip2p.py,sha256=GSEFJvrs4f2tv0xwYkWqc8uhsXrzAJVPvvwcw0gTjR0,619
|
|
@@ -79,7 +80,7 @@ bizyengine/misc/route_sam.py,sha256=-bMIR2QalfnszipGxSxvDAHGJa5gPSrjkYPb5baaRg4,
|
|
|
79
80
|
bizyengine/misc/segment_anything.py,sha256=wNKYwlYPMszfwj23524geFZJjZaG4eye65SGaUnh77I,8941
|
|
80
81
|
bizyengine/misc/supernode.py,sha256=STN9gaxfTSErH8OiHeZa47d8z-G9S0I7fXuJvHQOBFM,4532
|
|
81
82
|
bizyengine/misc/utils.py,sha256=CKduySGSMNGlJMImHyZmN-giABY5VUaB88f6Kq-HAV0,6831
|
|
82
|
-
bizyengine-1.2.
|
|
83
|
-
bizyengine-1.2.
|
|
84
|
-
bizyengine-1.2.
|
|
85
|
-
bizyengine-1.2.
|
|
83
|
+
bizyengine-1.2.49.dist-info/METADATA,sha256=HgvznMszXmVxmt_bEpKgowgsv5FNUfJLBukriYLIyLk,708
|
|
84
|
+
bizyengine-1.2.49.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
85
|
+
bizyengine-1.2.49.dist-info/top_level.txt,sha256=2zapzqxX-we5cRyJkGf9bd5JinRtXp3-_uDI-xCAnc0,11
|
|
86
|
+
bizyengine-1.2.49.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|