From 2a95e50739eda1e46db7d30ad45ba82dd4d11b29 Mon Sep 17 00:00:00 2001 From: Yanhong Zeng Date: Fri, 10 Nov 2023 16:13:31 +0800 Subject: [PATCH] [Fix] try import expand mask from transformers (#2064) * try import expand mask from transformers * fix lint * fix lint * fix lint --- mmagic/models/editors/fastcomposer/fastcomposer_util.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mmagic/models/editors/fastcomposer/fastcomposer_util.py b/mmagic/models/editors/fastcomposer/fastcomposer_util.py index fa9bf9c56a..55d9b62a0f 100644 --- a/mmagic/models/editors/fastcomposer/fastcomposer_util.py +++ b/mmagic/models/editors/fastcomposer/fastcomposer_util.py @@ -12,7 +12,13 @@ from transformers import (CLIPModel, CLIPPreTrainedModel, CLIPTextModel, CLIPVisionConfig, CLIPVisionModel) from transformers.modeling_outputs import BaseModelOutputWithPooling -from transformers.models.clip.modeling_clip import _expand_mask + +from mmagic.utils import try_import + +_expand_mask = try_import('transformers.models.clip.modeling_clip') +if _expand_mask is None: + _expand_mask = try_import( + 'ransformers.models.clip.modeling_clip._prepare_4d_attention_mask') class FastComposerModel(nn.Module):