Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
run-slow: detr, conditional_detr, beit, rt_detr, rt_detr_v2, dpt, depth_anything, prompt_depth_anything, mm_grounding_dino, grounding_dino, table_transformer, maskformer, oneformer, vitmatte, tvp, d_fine |
|
This comment contains models: ["models/beit", "models/conditional_detr", "models/d_fine", "models/depth_anything", "models/detr", "models/dpt", "models/grounding_dino", "models/maskformer", "models/mm_grounding_dino", "models/oneformer", "models/prompt_depth_anything", "models/rt_detr", "models/rt_detr_v2", "models/table_transformer", "models/tvp", "models/vitmatte"] |
| # Early exit for `timm` models, they aren't hosted on the hub usually | ||
| use_timm_backbone = kwargs.pop("use_timm_backbone", None) |
There was a problem hiding this comment.
let's keep it actually and use only when Autobackbone.from_pretrained(). We don't call from_pretrained anywhere across repo so it will be used only by users
Then we can delete _BaseAutoBackboneClass
| ("timesfm", "TimesFmConfig"), | ||
| ("timesformer", "TimesformerConfig"), | ||
| ("timm_backbone", "TimmBackboneConfig"), | ||
| ("timm_backbone", "TimmBackboneConfig"), # for BC |
There was a problem hiding this comment.
we should map any timm_backbone to the new model class when loading, so we don't log deprecation warnings. Mapping happens in the auto-modeling file
| @classmethod | ||
| def from_dict(cls, config_dict: dict[str, Any], **kwargs): | ||
| # Create a copy to avoid mutating the original dict | ||
| config_dict = config_dict.copy() |
There was a problem hiding this comment.
gemma3n vision is not a classifier and has no ImageClassificationModel, not needed!
| def __setattr__(self, key, value): | ||
| if (mapped_key := super().__getattribute__("special_attribute_map").get(key)) is not None: | ||
| if isinstance(mapped_key, (tuple, list)): | ||
| model_args = super().__getattribute__("__dict__").get(mapped_key[0]) | ||
| model_args[mapped_key[1]] = value | ||
| else: | ||
| setattr(self, mapped_key[1], value) | ||
| else: | ||
| super().__setattr__(key, value) | ||
|
|
There was a problem hiding this comment.
weird way to keep BC for setter/getter
| self.architecture = architecture | ||
| is_backbone_config = kwargs.get("backbone") is not None | ||
| self.architecture = kwargs.pop("backbone") if is_backbone_config else architecture |
There was a problem hiding this comment.
allows loading old timm_backbone configs. No idea if we should log warnings, we can't deprecate it away from hub ckpt
| output_attentions: bool | None = None, | ||
| output_hidden_states: bool | list[int] | None = None, | ||
| return_dict: bool | None = None, | ||
| do_pooling: bool | None = None, | ||
| use_cache: bool | None = None, |
There was a problem hiding this comment.
wanted to get rid of all, but we can't unless we use capture_outputs 🥲
|
run-slow: detr, conditional_detr, beit, rt_detr, rt_detr_v2, dpt, depth_anything, prompt_depth_anything, mm_grounding_dino, grounding_dino, table_transformer, maskformer, oneformer, vitmatte, tvp, d_fine |
|
This comment contains models: ["models/beit", "models/conditional_detr", "models/d_fine", "models/depth_anything", "models/detr", "models/dpt", "models/grounding_dino", "models/maskformer", "models/mm_grounding_dino", "models/oneformer", "models/prompt_depth_anything", "models/rt_detr", "models/rt_detr_v2", "models/table_transformer", "models/tvp", "models/vitmatte"] |
| self.config = config | ||
|
|
||
| backbone = load_backbone(config) | ||
| backbone = AutoBackbone.from_config(config=config.backbone_config) |
There was a problem hiding this comment.
goodbye load_backbone 👋🏻
now we can replace it with one-line from_config
| "timm_wrapper": [ | ||
| # Simply add the prefix `timm_model` | ||
| # TODO: Would be probably much cleaner with a `add_prefix` argument in WeightRenaming |
There was a problem hiding this comment.
base_model_prefix can do pretty well and doesn't have false-positive matches when reverse mapping
| for k, v in model._checkpoint_conversion_mapping.items() | ||
| ] | ||
|
|
||
| # TODO: should be checked recursively on submodels!! |
There was a problem hiding this comment.
needed it for timm, so we can define it once in above mapping and re-use in all models where Timm is a backbone
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto, colpali, colqwen2, conditional_detr, d_fine, dab_detr, deformable_detr, depth_anything, detr, dpt, gemma3n, grounding_dino |
What does this PR do?
Deprecate timm backbone in favor of keeping all models within one
timmfolder, similar to other vision models. A backbone is just a variation ofPreTrainedModel