Skip to content

Commit 3000551

Browse files
authored
Update UNet2DConditionModel's error messages (#9230)
* refactor
1 parent 249a9e4 commit 3000551

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/diffusers/models/unets/unet_2d_condition.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ def __init__(
463463
dropout=dropout,
464464
)
465465
self.up_blocks.append(up_block)
466-
prev_output_channel = output_channel
467466

468467
# out
469468
if norm_num_groups is not None:
@@ -599,7 +598,7 @@ def _set_encoder_hid_proj(
599598
)
600599
elif encoder_hid_dim_type is not None:
601600
raise ValueError(
602-
f"encoder_hid_dim_type: {encoder_hid_dim_type} must be None, 'text_proj' or 'text_image_proj'."
601+
f"`encoder_hid_dim_type`: {encoder_hid_dim_type} must be None, 'text_proj', 'text_image_proj', or 'image_proj'."
603602
)
604603
else:
605604
self.encoder_hid_proj = None
@@ -679,7 +678,9 @@ def _set_add_embedding(
679678
# Kandinsky 2.2 ControlNet
680679
self.add_embedding = ImageHintTimeEmbedding(image_embed_dim=encoder_hid_dim, time_embed_dim=time_embed_dim)
681680
elif addition_embed_type is not None:
682-
raise ValueError(f"addition_embed_type: {addition_embed_type} must be None, 'text' or 'text_image'.")
681+
raise ValueError(
682+
f"`addition_embed_type`: {addition_embed_type} must be None, 'text', 'text_image', 'text_time', 'image', or 'image_hint'."
683+
)
683684

684685
def _set_pos_net_if_use_gligen(self, attention_type: str, cross_attention_dim: int):
685686
if attention_type in ["gated", "gated-text-image"]:
@@ -990,7 +991,7 @@ def get_aug_embed(
990991
image_embs = added_cond_kwargs.get("image_embeds")
991992
aug_emb = self.add_embedding(image_embs)
992993
elif self.config.addition_embed_type == "image_hint":
993-
# Kandinsky 2.2 - style
994+
# Kandinsky 2.2 ControlNet - style
994995
if "image_embeds" not in added_cond_kwargs or "hint" not in added_cond_kwargs:
995996
raise ValueError(
996997
f"{self.__class__} has the config param `addition_embed_type` set to 'image_hint' which requires the keyword arguments `image_embeds` and `hint` to be passed in `added_cond_kwargs`"
@@ -1009,7 +1010,7 @@ def process_encoder_hidden_states(
10091010
# Kandinsky 2.1 - style
10101011
if "image_embeds" not in added_cond_kwargs:
10111012
raise ValueError(
1012-
f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'text_image_proj' which requires the keyword argument `image_embeds` to be passed in `added_conditions`"
1013+
f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'text_image_proj' which requires the keyword argument `image_embeds` to be passed in `added_cond_kwargs`"
10131014
)
10141015

10151016
image_embeds = added_cond_kwargs.get("image_embeds")
@@ -1018,14 +1019,14 @@ def process_encoder_hidden_states(
10181019
# Kandinsky 2.2 - style
10191020
if "image_embeds" not in added_cond_kwargs:
10201021
raise ValueError(
1021-
f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'image_proj' which requires the keyword argument `image_embeds` to be passed in `added_conditions`"
1022+
f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'image_proj' which requires the keyword argument `image_embeds` to be passed in `added_cond_kwargs`"
10221023
)
10231024
image_embeds = added_cond_kwargs.get("image_embeds")
10241025
encoder_hidden_states = self.encoder_hid_proj(image_embeds)
10251026
elif self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == "ip_image_proj":
10261027
if "image_embeds" not in added_cond_kwargs:
10271028
raise ValueError(
1028-
f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'ip_image_proj' which requires the keyword argument `image_embeds` to be passed in `added_conditions`"
1029+
f"{self.__class__} has the config param `encoder_hid_dim_type` set to 'ip_image_proj' which requires the keyword argument `image_embeds` to be passed in `added_cond_kwargs`"
10291030
)
10301031

10311032
if hasattr(self, "text_encoder_hid_proj") and self.text_encoder_hid_proj is not None:
@@ -1140,7 +1141,6 @@ def forward(
11401141
# 1. time
11411142
t_emb = self.get_time_embed(sample=sample, timestep=timestep)
11421143
emb = self.time_embedding(t_emb, timestep_cond)
1143-
aug_emb = None
11441144

11451145
class_emb = self.get_class_embed(sample=sample, class_labels=class_labels)
11461146
if class_emb is not None:

src/diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def __init__(
546546
)
547547
elif encoder_hid_dim_type is not None:
548548
raise ValueError(
549-
f"encoder_hid_dim_type: {encoder_hid_dim_type} must be None, 'text_proj' or 'text_image_proj'."
549+
f"`encoder_hid_dim_type`: {encoder_hid_dim_type} must be None, 'text_proj', 'text_image_proj' or 'image_proj'."
550550
)
551551
else:
552552
self.encoder_hid_proj = None

0 commit comments

Comments
 (0)