From 1e2777bab14b2d9332645c14a1b2755ff07768d9 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Tue, 8 Oct 2024 17:52:01 -0500 Subject: [PATCH] Added uuid to conds in CFGGuider and uuids to transformer_options to allow uniquely identifying conds in batches during sampling --- comfy/sampler_helpers.py | 2 ++ comfy/samplers.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/comfy/sampler_helpers.py b/comfy/sampler_helpers.py index 0e911b3ff..a84778507 100644 --- a/comfy/sampler_helpers.py +++ b/comfy/sampler_helpers.py @@ -1,4 +1,5 @@ from __future__ import annotations +import uuid import torch import comfy.model_management import comfy.conds @@ -45,6 +46,7 @@ def convert_cond(cond): model_conds["c_crossattn"] = comfy.conds.CONDCrossAttn(c[0]) #TODO: remove temp["cross_attn"] = c[0] temp["model_conds"] = model_conds + temp["uuid"] = uuid.uuid4() out.append(temp) return out diff --git a/comfy/samplers.py b/comfy/samplers.py index 79bd00c0c..05e3bd6d3 100644 --- a/comfy/samplers.py +++ b/comfy/samplers.py @@ -91,8 +91,8 @@ def get_area_and_mult(conds, x_in, timestep_in): patches['middle_patch'] = [gligen_patch] - cond_obj = collections.namedtuple('cond_obj', ['input_x', 'mult', 'conditioning', 'area', 'control', 'patches']) - return cond_obj(input_x, mult, conditioning, area, control, patches) + cond_obj = collections.namedtuple('cond_obj', ['input_x', 'mult', 'conditioning', 'area', 'control', 'patches', 'uuid']) + return cond_obj(input_x, mult, conditioning, area, control, patches, conds['uuid']) def cond_equal_size(c1, c2): if c1 is c2: @@ -252,6 +252,7 @@ def outer_calc_cond_batch(model: 'BaseModel', conds: list[list[dict]], x_in: tor mult = [] c = [] cond_or_uncond = [] + uuids = [] area = [] control = None patches = None @@ -263,6 +264,7 @@ def outer_calc_cond_batch(model: 'BaseModel', conds: list[list[dict]], x_in: tor c.append(p.conditioning) area.append(p.area) cond_or_uncond.append(o[1]) + uuids.append(p.uuid) control = p.control patches = p.patches @@ -288,6 +290,7 @@ def outer_calc_cond_batch(model: 'BaseModel', conds: list[list[dict]], x_in: tor transformer_options["patches"] = patches transformer_options["cond_or_uncond"] = cond_or_uncond[:] + transformer_options["uuids"] = uuids[:] transformer_options["sigmas"] = timestep c['transformer_options'] = transformer_options