MCPcopy Create free account
hub / github.com/cubiq/ComfyUI_IPAdapter_plus / batch

Method batch

IPAdapterPlus.py:1445–1467  ·  view source on GitHub ↗
(self, embed1, method, embed2=None, embed3=None, embed4=None, embed5=None)

Source from the content-addressed store, hash-verified

1443 CATEGORY = "ipadapter/embeds"
1444
1445 def batch(self, embed1, method, embed2=None, embed3=None, embed4=None, embed5=None):
1446 if method=='concat' and embed2 is None and embed3 is None and embed4 is None and embed5 is None:
1447 return (embed1, )
1448
1449 embeds = [embed1, embed2, embed3, embed4, embed5]
1450 embeds = [embed for embed in embeds if embed is not None]
1451 embeds = torch.cat(embeds, dim=0)
1452
1453 if method == "add":
1454 embeds = torch.sum(embeds, dim=0).unsqueeze(0)
1455 elif method == "subtract":
1456 embeds = embeds[0] - torch.mean(embeds[1:], dim=0)
1457 embeds = embeds.unsqueeze(0)
1458 elif method == "average":
1459 embeds = torch.mean(embeds, dim=0).unsqueeze(0)
1460 elif method == "norm average":
1461 embeds = torch.mean(embeds / torch.norm(embeds, dim=0, keepdim=True), dim=0).unsqueeze(0)
1462 elif method == "max":
1463 embeds = torch.max(embeds, dim=0).values.unsqueeze(0)
1464 elif method == "min":
1465 embeds = torch.min(embeds, dim=0).values.unsqueeze(0)
1466
1467 return (embeds, )
1468
1469class IPAdapterNoise:
1470 @classmethod

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected