diff --git a/src/transformers/models/maskformer/modeling_maskformer.py b/src/transformers/models/maskformer/modeling_maskformer.py index eef31ba2799a45..f2b171b32dc9e4 100644 --- a/src/transformers/models/maskformer/modeling_maskformer.py +++ b/src/transformers/models/maskformer/modeling_maskformer.py @@ -1439,7 +1439,7 @@ def __init__(self, config: MaskFormerConfig): The configuration used to instantiate this model. """ super().__init__() - if hasattr(config, "backbone_config") and config.backbone_config.model_type == "swin": + if getattr(config, "backbone_config") is not None and config.backbone_config.model_type == "swin": # for backwards compatibility backbone_config = config.backbone_config backbone_config = MaskFormerSwinConfig.from_dict(backbone_config.to_dict())