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 ArthurZucker committed Feb 21, 2024
1 parent 476957b commit 2de9314
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 2de9314

Please sign in to comment.