Skip to content

Commit

Permalink
[Maskformer] safely get backbone config (#29166)
Browse files Browse the repository at this point in the history
Safe getattr
  • Loading branch information
amyeroberts authored and Ita Zaporozhets committed May 14, 2024
1 parent 4cc641b commit e0ab976
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/models/maskformer/modeling_maskformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit e0ab976

Please sign in to comment.