| 66 | |
| 67 | |
| 68 | class FluxMultiControlNetManager(MultiControlNetManager): |
| 69 | def __init__(self, controlnet_units=[]): |
| 70 | super().__init__(controlnet_units=controlnet_units) |
| 71 | |
| 72 | def process_image(self, image, processor_id=None): |
| 73 | if processor_id is None: |
| 74 | processed_image = [processor(image) for processor in self.processors] |
| 75 | else: |
| 76 | processed_image = [self.processors[processor_id](image)] |
| 77 | return processed_image |
| 78 | |
| 79 | def __call__(self, conditionings, **kwargs): |
| 80 | res_stack, single_res_stack = None, None |
| 81 | for processor, conditioning, model, scale in zip(self.processors, conditionings, self.models, self.scales): |
| 82 | res_stack_, single_res_stack_ = model(controlnet_conditioning=conditioning, processor_id=processor.processor_id, **kwargs) |
| 83 | res_stack_ = [res * scale for res in res_stack_] |
| 84 | single_res_stack_ = [res * scale for res in single_res_stack_] |
| 85 | if res_stack is None: |
| 86 | res_stack = res_stack_ |
| 87 | single_res_stack = single_res_stack_ |
| 88 | else: |
| 89 | res_stack = [i + j for i, j in zip(res_stack, res_stack_)] |
| 90 | single_res_stack = [i + j for i, j in zip(single_res_stack, single_res_stack_)] |
| 91 | return res_stack, single_res_stack |