feat: allow to use hf-hub models for timm backbone (#34729)

Currently a backbone name like 'hf-hub:bioptimus/H-optimus-0' throws an
error, even though it could work.

Co-authored-by: Christian Gebbe <>
This commit is contained in:
gebbissimo 2024-11-19 11:26:35 +01:00 committed by GitHub
parent d8a5d31d9c
commit 1a0cd69435
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,11 +50,6 @@ class TimmBackbone(PreTrainedModel, BackboneMixin):
if config.backbone is None:
raise ValueError("backbone is not set in the config. Please set it to a timm model name.")
# Certain timm models have the structure `model_name.version` e.g. vit_large_patch14_dinov2.lvd142m
base_backbone_model = config.backbone.split(".")[0]
if base_backbone_model not in timm.list_models():
raise ValueError(f"backbone {base_backbone_model} is not supported by timm.")
if hasattr(config, "out_features") and config.out_features is not None:
raise ValueError("out_features is not supported by TimmBackbone. Please use out_indices instead.")