(self, model, ipadapter, start_at=0.0, end_at=1.0, weight=1.0, weight_style=1.0, weight_composition=1.0, expand_style=False, weight_type="linear", combine_embeds="concat", weight_faceidv2=None, image=None, image_style=None, image_composition=None, image_negative=None, clip_vision=None, attn_mask=None, insightface=None, embeds_scaling='V only', layer_weights=None, ipadapter_params=None, encode_batch_size=0, style_boost=None, composition_boost=None, enhance_tiles=1, enhance_ratio=1.0, weight_kolors=1.0)
| 781 | CATEGORY = "ipadapter" |
| 782 | |
| 783 | def apply_ipadapter(self, model, ipadapter, start_at=0.0, end_at=1.0, weight=1.0, weight_style=1.0, weight_composition=1.0, expand_style=False, weight_type="linear", combine_embeds="concat", weight_faceidv2=None, image=None, image_style=None, image_composition=None, image_negative=None, clip_vision=None, attn_mask=None, insightface=None, embeds_scaling='V only', layer_weights=None, ipadapter_params=None, encode_batch_size=0, style_boost=None, composition_boost=None, enhance_tiles=1, enhance_ratio=1.0, weight_kolors=1.0): |
| 784 | is_sdxl = isinstance(model.model, (comfy.model_base.SDXL, comfy.model_base.SDXLRefiner, comfy.model_base.SDXL_instructpix2pix)) |
| 785 | |
| 786 | if 'ipadapter' in ipadapter: |
| 787 | ipadapter_model = ipadapter['ipadapter']['model'] |
| 788 | clip_vision = clip_vision if clip_vision is not None else ipadapter['clipvision']['model'] |
| 789 | else: |
| 790 | ipadapter_model = ipadapter |
| 791 | |
| 792 | if clip_vision is None: |
| 793 | raise Exception("Missing CLIPVision model.") |
| 794 | |
| 795 | if image_style is not None: # we are doing style + composition transfer |
| 796 | if not is_sdxl: |
| 797 | raise Exception("Style + Composition transfer is only available for SDXL models at the moment.") # TODO: check feasibility for SD1.5 models |
| 798 | |
| 799 | image = image_style |
| 800 | weight = weight_style |
| 801 | if image_composition is None: |
| 802 | image_composition = image_style |
| 803 | |
| 804 | weight_type = "strong style and composition" if expand_style else "style and composition" |
| 805 | if ipadapter_params is not None: # we are doing batch processing |
| 806 | image = ipadapter_params['image'] |
| 807 | attn_mask = ipadapter_params['attn_mask'] |
| 808 | weight = ipadapter_params['weight'] |
| 809 | weight_type = ipadapter_params['weight_type'] |
| 810 | start_at = ipadapter_params['start_at'] |
| 811 | end_at = ipadapter_params['end_at'] |
| 812 | else: |
| 813 | # at this point weight can be a list from the batch-weight or a single float |
| 814 | weight = [weight] |
| 815 | |
| 816 | image = image if isinstance(image, list) else [image] |
| 817 | |
| 818 | work_model = model.clone() |
| 819 | |
| 820 | for i in range(len(image)): |
| 821 | if image[i] is None: |
| 822 | continue |
| 823 | |
| 824 | ipa_args = { |
| 825 | "image": image[i], |
| 826 | "image_composition": image_composition, |
| 827 | "image_negative": image_negative, |
| 828 | "weight": weight[i], |
| 829 | "weight_composition": weight_composition, |
| 830 | "weight_faceidv2": weight_faceidv2, |
| 831 | "weight_type": weight_type if not isinstance(weight_type, list) else weight_type[i], |
| 832 | "combine_embeds": combine_embeds, |
| 833 | "start_at": start_at if not isinstance(start_at, list) else start_at[i], |
| 834 | "end_at": end_at if not isinstance(end_at, list) else end_at[i], |
| 835 | "attn_mask": attn_mask if not isinstance(attn_mask, list) else attn_mask[i], |
| 836 | "unfold_batch": self.unfold_batch, |
| 837 | "embeds_scaling": embeds_scaling, |
| 838 | "insightface": insightface if insightface is not None else ipadapter['insightface']['model'] if 'insightface' in ipadapter else None, |
| 839 | "layer_weights": layer_weights, |
| 840 | "encode_batch_size": encode_batch_size, |
nothing calls this directly
no test coverage detected