feat: 新增去背景/PSD分层导出节点,优化聊天面板与重启逻辑
- 新增 O1keyRemoveBackground 节点(基于 rembg CPU 推理) - 新增 O1keyColorRemoveBG 节点(颜色距离去背景,支持多模式) - 新增 O1keySavePSD 节点(手写 PSD 二进制,零外部依赖) - GPT Image 批量输出不同尺寸时自动 resize 对齐 - 聊天面板大幅增强(多模态/交互优化) - 重启按钮绕过 beforeunload 弹窗强制刷新 - 默认路由切换为 CF加速 - http_error 新增 system error 友好文案 Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
@@ -173,7 +173,20 @@ class GptImageClient:
|
||||
arr = np.array(img.convert("RGBA")).astype(np.float32) / 255.0
|
||||
tensors.append(torch.from_numpy(arr))
|
||||
|
||||
return torch.stack(tensors, dim=0) # [B, H, W, 4]
|
||||
# 批量模式下 API 可能返回不同尺寸,统一 resize 到最大尺寸
|
||||
max_h = max(t.shape[0] for t in tensors)
|
||||
max_w = max(t.shape[1] for t in tensors)
|
||||
aligned = []
|
||||
for t in tensors:
|
||||
if t.shape[0] != max_h or t.shape[1] != max_w:
|
||||
t = t.permute(2, 0, 1).unsqueeze(0) # [1, C, H, W]
|
||||
t = torch.nn.functional.interpolate(
|
||||
t, size=(max_h, max_w), mode="bilinear", align_corners=False
|
||||
)
|
||||
t = t.squeeze(0).permute(1, 2, 0) # [H, W, C]
|
||||
aligned.append(t)
|
||||
|
||||
return torch.stack(aligned, dim=0) # [B, H, W, 4]
|
||||
|
||||
# ── 响应解析(通用) ─────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user