From 12285199771c68ba82183fcce6a208ad8b10d6ba Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Sat, 20 Sep 2025 11:07:17 +0200 Subject: [PATCH 1/9] Adding licensing information to cspnet.py --- timm/models/_hub.py | 45 +++++++++++++++++++++++++++++++++++++++++-- timm/models/cspnet.py | 20 +++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index 00d3d750da..ef9bf842c0 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -30,8 +30,8 @@ from timm.models._pretrained import filter_pretrained_cfg try: - from huggingface_hub import HfApi, hf_hub_download - from huggingface_hub.utils import EntryNotFoundError + from huggingface_hub import HfApi, hf_hub_download, model_info + from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError hf_hub_download = partial(hf_hub_download, library_name="timm", library_version=__version__) _has_hf_hub = True except ImportError: @@ -533,3 +533,44 @@ def _get_safe_alternatives(filename: str) -> Iterable[str]: yield HF_OPEN_CLIP_SAFE_WEIGHTS_NAME if filename not in (HF_WEIGHTS_NAME, HF_OPEN_CLIP_WEIGHTS_NAME) and filename.endswith(".bin"): yield filename[:-4] + ".safetensors" + + +def _get_license_from_hf_hub(model_id: str | None, hf_hub_id: str | None) -> str | None: + """Retrieve license information for a model from Hugging Face Hub. + + Fetches the license field from the model card metadata on Hugging Face Hub + for the specified model. Returns None if the model is not found, if + huggingface_hub is not installed, or if the model is marked as "untrained". + + Args: + model_id: The model identifier/name. In the case of None we assume an untrained model. + hf_hub_id: The Hugging Face Hub organization/user ID. If it is None, + we will return None as we cannot infer the license terms. + + Returns: + The license string in lowercase if found, None otherwise. + + Note: + Requires huggingface_hub package to be installed. Will log a warning + and return None if the package is not available. + """ + if not has_hf_hub(True): + msg = "For updated license information run `pip install huggingface_hub`." + _logger.warning(msg=msg) + return None + + if not (model_id and hf_hub_id): + return None + + repo_id: str = hf_hub_id + model_id + + try: + info = model_info(repo_id=repo_id) + + except RepositoryNotFoundError: + # TODO: any wish what happens here? @rwightman + print(repo_id) + return None + + license = info.card_data.get("license").lower() if info.card_data else None + return license diff --git a/timm/models/cspnet.py b/timm/models/cspnet.py index 6de3b354ee..45228635d9 100644 --- a/timm/models/cspnet.py +++ b/timm/models/cspnet.py @@ -22,6 +22,7 @@ from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from timm.layers import ClassifierHead, ConvNormAct, DropPath, calculate_drop_path_rates, get_attn, create_act_layer, make_divisible from ._builder import build_model_with_cfg +from ._hub import _get_license_from_hf_hub from ._manipulate import named_apply, MATCH_PREV_GROUP from ._registry import register_model, generate_default_cfgs @@ -1011,22 +1012,25 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.887, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1.conv', 'classifier': 'head.fc', + 'license': _get_license_from_hf_hub(kwargs.pop('model_id', None), kwargs.get('hf_hub_id')), **kwargs } - default_cfgs = generate_default_cfgs({ 'cspresnet50.ra_in1k': _cfg( hf_hub_id='timm/', + model_id='cspresnet50.ra_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/cspresnet50_ra-d3e8d487.pth'), 'cspresnet50d.untrained': _cfg(), 'cspresnet50w.untrained': _cfg(), 'cspresnext50.ra_in1k': _cfg( hf_hub_id='timm/', + model_id='cspresnext50.ra_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/cspresnext50_ra_224-648b4713.pth', ), 'cspdarknet53.ra_in1k': _cfg( hf_hub_id='timm/', + model_id='cspdarknet53.ra_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/cspdarknet53_ra_256-d05c7c21.pth'), 'darknet17.untrained': _cfg(), @@ -1034,48 +1038,58 @@ def _cfg(url='', **kwargs): 'sedarknet21.untrained': _cfg(), 'darknet53.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='darknet53.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/darknet53_256_c2ns-3aeff817.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=1.0), 'darknetaa53.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='darknetaa53.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/darknetaa53_c2ns-5c28ec8a.pth', test_input_size=(3, 288, 288), test_crop_pct=1.0), 'cs3darknet_s.untrained': _cfg(interpolation='bicubic'), 'cs3darknet_m.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3darknet_m.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_m_c2ns-43f06604.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95, ), 'cs3darknet_l.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3darknet_l.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_l_c2ns-16220c5d.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3darknet_x.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3darknet_x.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_x_c2ns-4e4490aa.pth', interpolation='bicubic', crop_pct=0.95, test_input_size=(3, 288, 288), test_crop_pct=1.0), 'cs3darknet_focus_s.ra4_e3600_r256_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3darknet_focus_s.ra4_e3600_r256_in1k', mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5), interpolation='bicubic', test_input_size=(3, 320, 320), test_crop_pct=1.0), 'cs3darknet_focus_m.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3darknet_focus_m.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_focus_m_c2ns-e23bed41.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3darknet_focus_l.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3darknet_focus_l.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_focus_l_c2ns-65ef8888.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3darknet_focus_x.untrained': _cfg(interpolation='bicubic'), 'cs3sedarknet_l.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3sedarknet_l.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3sedarknet_l_c2ns-e8d1dc13.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3sedarknet_x.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3sedarknet_x.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3sedarknet_x_c2ns-b4d0abc0.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=1.0), @@ -1083,10 +1097,12 @@ def _cfg(url='', **kwargs): 'cs3edgenet_x.c2_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3edgenet_x.c2_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3edgenet_x_c2-2e1610a9.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=1.0), 'cs3se_edgenet_x.c2ns_in1k': _cfg( hf_hub_id='timm/', + model_id='cs3se_edgenet_x.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3se_edgenet_x_c2ns-76f8e3ac.pth', interpolation='bicubic', crop_pct=0.95, test_input_size=(3, 320, 320), test_crop_pct=1.0), }) @@ -1204,4 +1220,4 @@ def cs3edgenet_x(pretrained=False, **kwargs) -> CspNet: @register_model def cs3se_edgenet_x(pretrained=False, **kwargs) -> CspNet: - return _create_cspnet('cs3se_edgenet_x', pretrained=pretrained, **kwargs) \ No newline at end of file + return _create_cspnet('cs3se_edgenet_x', pretrained=pretrained, **kwargs) From ffddf592c3c7add707742c4d9d17078a3dc1fde2 Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Sat, 20 Sep 2025 11:10:14 +0200 Subject: [PATCH 2/9] Running formatting with command from CONTRIBUTING.md - Skipping the cspnet.py file with formatting due to large diff --- timm/models/_hub.py | 128 +++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 60 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index ef9bf842c0..01693ee8bf 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -17,6 +17,7 @@ try: import safetensors.torch + _has_safetensors = True except ImportError: _has_safetensors = False @@ -32,6 +33,7 @@ try: from huggingface_hub import HfApi, hf_hub_download, model_info from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError + hf_hub_download = partial(hf_hub_download, library_name="timm", library_version=__version__) _has_hf_hub = True except ImportError: @@ -40,8 +42,16 @@ _logger = logging.getLogger(__name__) -__all__ = ['get_cache_dir', 'download_cached_file', 'has_hf_hub', 'hf_split', 'load_model_config_from_hf', - 'load_state_dict_from_hf', 'save_for_hf', 'push_to_hf_hub'] +__all__ = [ + 'get_cache_dir', + 'download_cached_file', + 'has_hf_hub', + 'hf_split', + 'load_model_config_from_hf', + 'load_state_dict_from_hf', + 'save_for_hf', + 'push_to_hf_hub', +] # Default name for a weights file hosted on the Huggingface Hub. HF_WEIGHTS_NAME = "pytorch_model.bin" # default pytorch pkl @@ -66,10 +76,10 @@ def get_cache_dir(child_dir: str = ''): def download_cached_file( - url: Union[str, List[str], Tuple[str, str]], - check_hash: bool = True, - progress: bool = False, - cache_dir: Optional[Union[str, Path]] = None, + url: Union[str, List[str], Tuple[str, str]], + check_hash: bool = True, + progress: bool = False, + cache_dir: Optional[Union[str, Path]] = None, ): if isinstance(url, (list, tuple)): url, filename = url @@ -92,9 +102,9 @@ def download_cached_file( def check_cached_file( - url: Union[str, List[str], Tuple[str, str]], - check_hash: bool = True, - cache_dir: Optional[Union[str, Path]] = None, + url: Union[str, List[str], Tuple[str, str]], + check_hash: bool = True, + cache_dir: Optional[Union[str, Path]] = None, ): if isinstance(url, (list, tuple)): url, filename = url @@ -111,7 +121,7 @@ def check_cached_file( if hash_prefix: with open(cached_file, 'rb') as f: hd = hashlib.sha256(f.read()).hexdigest() - if hd[:len(hash_prefix)] != hash_prefix: + if hd[: len(hash_prefix)] != hash_prefix: return False return True return False @@ -121,7 +131,8 @@ def has_hf_hub(necessary: bool = False): if not _has_hf_hub and necessary: # if no HF Hub module installed, and it is necessary to continue, raise error raise RuntimeError( - 'Hugging Face hub model specified but package not installed. Run `pip install huggingface_hub`.') + 'Hugging Face hub model specified but package not installed. Run `pip install huggingface_hub`.' + ) return _has_hf_hub @@ -141,9 +152,9 @@ def load_cfg_from_json(json_file: Union[str, Path]): def download_from_hf( - model_id: str, - filename: str, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + filename: str, + cache_dir: Optional[Union[str, Path]] = None, ): hf_model_id, hf_revision = hf_split(model_id) return hf_hub_download( @@ -155,8 +166,8 @@ def download_from_hf( def _parse_model_cfg( - cfg: Dict[str, Any], - extra_fields: Dict[str, Any], + cfg: Dict[str, Any], + extra_fields: Dict[str, Any], ) -> Tuple[Dict[str, Any], str, Dict[str, Any]]: """""" # legacy "single‑dict" → split @@ -167,7 +178,7 @@ def _parse_model_cfg( "num_features": pretrained_cfg.pop("num_features", None), "pretrained_cfg": pretrained_cfg, } - if "labels" in pretrained_cfg: # rename ‑‑> label_names + if "labels" in pretrained_cfg: # rename ‑‑> label_names pretrained_cfg["label_names"] = pretrained_cfg.pop("labels") pretrained_cfg = cfg["pretrained_cfg"] @@ -187,8 +198,8 @@ def _parse_model_cfg( def load_model_config_from_hf( - model_id: str, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + cache_dir: Optional[Union[str, Path]] = None, ): """Original HF‑Hub loader (unchanged download, shared parsing).""" assert has_hf_hub(True) @@ -198,7 +209,7 @@ def load_model_config_from_hf( def load_model_config_from_path( - model_path: Union[str, Path], + model_path: Union[str, Path], ): """Load from ``/config.json`` on the local filesystem.""" model_path = Path(model_path) @@ -211,10 +222,10 @@ def load_model_config_from_path( def load_state_dict_from_hf( - model_id: str, - filename: str = HF_WEIGHTS_NAME, - weights_only: bool = False, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + filename: str = HF_WEIGHTS_NAME, + weights_only: bool = False, + cache_dir: Optional[Union[str, Path]] = None, ): assert has_hf_hub(True) hf_model_id, hf_revision = hf_split(model_id) @@ -231,7 +242,8 @@ def load_state_dict_from_hf( ) _logger.info( f"[{model_id}] Safe alternative available for '{filename}' " - f"(as '{safe_filename}'). Loading weights using safetensors.") + f"(as '{safe_filename}'). Loading weights using safetensors." + ) return safetensors.torch.load_file(cached_safe_file, device="cpu") except EntryNotFoundError: pass @@ -263,9 +275,10 @@ def load_state_dict_from_hf( ) _EXT_PRIORITY = ('.safetensors', '.pth', '.pth.tar', '.bin') + def load_state_dict_from_path( - path: str, - weights_only: bool = False, + path: str, + weights_only: bool = False, ): found_file = None for fname in _PREFERRED_FILES: @@ -280,10 +293,7 @@ def load_state_dict_from_path( files = sorted(path.glob(f"*{ext}")) if files: if len(files) > 1: - logging.warning( - f"Multiple {ext} checkpoints in {path}: {names}. " - f"Using '{files[0].name}'." - ) + logging.warning(f"Multiple {ext} checkpoints in {path}: {names}. " f"Using '{files[0].name}'.") found_file = files[0] if not found_file: @@ -297,10 +307,10 @@ def load_state_dict_from_path( def load_custom_from_hf( - model_id: str, - filename: str, - model: torch.nn.Module, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + filename: str, + model: torch.nn.Module, + cache_dir: Optional[Union[str, Path]] = None, ): assert has_hf_hub(True) hf_model_id, hf_revision = hf_split(model_id) @@ -314,10 +324,7 @@ def load_custom_from_hf( def save_config_for_hf( - model: torch.nn.Module, - config_path: str, - model_config: Optional[dict] = None, - model_args: Optional[dict] = None + model: torch.nn.Module, config_path: str, model_config: Optional[dict] = None, model_args: Optional[dict] = None ): model_config = model_config or {} hf_config = {} @@ -336,7 +343,8 @@ def save_config_for_hf( if 'labels' in model_config: _logger.warning( "'labels' as a config field for is deprecated. Please use 'label_names' and 'label_descriptions'." - " Renaming provided 'labels' field to 'label_names'.") + " Renaming provided 'labels' field to 'label_names'." + ) model_config.setdefault('label_names', model_config.pop('labels')) label_names = model_config.pop('label_names', None) @@ -363,11 +371,11 @@ def save_config_for_hf( def save_for_hf( - model: torch.nn.Module, - save_directory: str, - model_config: Optional[dict] = None, - model_args: Optional[dict] = None, - safe_serialization: Union[bool, Literal["both"]] = False, + model: torch.nn.Module, + save_directory: str, + model_config: Optional[dict] = None, + model_args: Optional[dict] = None, + safe_serialization: Union[bool, Literal["both"]] = False, ): assert has_hf_hub(True) save_directory = Path(save_directory) @@ -391,18 +399,18 @@ def save_for_hf( def push_to_hf_hub( - model: torch.nn.Module, - repo_id: str, - commit_message: str = 'Add model', - token: Optional[str] = None, - revision: Optional[str] = None, - private: bool = False, - create_pr: bool = False, - model_config: Optional[dict] = None, - model_card: Optional[dict] = None, - model_args: Optional[dict] = None, - task_name: str = 'image-classification', - safe_serialization: Union[bool, Literal["both"]] = 'both', + model: torch.nn.Module, + repo_id: str, + commit_message: str = 'Add model', + token: Optional[str] = None, + revision: Optional[str] = None, + private: bool = False, + create_pr: bool = False, + model_config: Optional[dict] = None, + model_card: Optional[dict] = None, + model_args: Optional[dict] = None, + task_name: str = 'image-classification', + safe_serialization: Union[bool, Literal["both"]] = 'both', ): """ Arguments: @@ -452,9 +460,9 @@ def push_to_hf_hub( def generate_readme( - model_card: dict, - model_name: str, - task_name: str = 'image-classification', + model_card: dict, + model_name: str, + task_name: str = 'image-classification', ): tags = model_card.get('tags', None) or [task_name, 'timm', 'transformers'] readme_text = "---\n" From f619bef00eaf48551149952415b7ab75b4eb8fa1 Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Mon, 22 Sep 2025 20:05:06 +0200 Subject: [PATCH 3/9] Revert "Running formatting with command from CONTRIBUTING.md" This reverts commit ed00d06c8cd9c430a5e0f112004fc2cdcd08976a. Reducing diff to keep pull request only for functional change. --- timm/models/_hub.py | 128 +++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 68 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index 01693ee8bf..ef9bf842c0 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -17,7 +17,6 @@ try: import safetensors.torch - _has_safetensors = True except ImportError: _has_safetensors = False @@ -33,7 +32,6 @@ try: from huggingface_hub import HfApi, hf_hub_download, model_info from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError - hf_hub_download = partial(hf_hub_download, library_name="timm", library_version=__version__) _has_hf_hub = True except ImportError: @@ -42,16 +40,8 @@ _logger = logging.getLogger(__name__) -__all__ = [ - 'get_cache_dir', - 'download_cached_file', - 'has_hf_hub', - 'hf_split', - 'load_model_config_from_hf', - 'load_state_dict_from_hf', - 'save_for_hf', - 'push_to_hf_hub', -] +__all__ = ['get_cache_dir', 'download_cached_file', 'has_hf_hub', 'hf_split', 'load_model_config_from_hf', + 'load_state_dict_from_hf', 'save_for_hf', 'push_to_hf_hub'] # Default name for a weights file hosted on the Huggingface Hub. HF_WEIGHTS_NAME = "pytorch_model.bin" # default pytorch pkl @@ -76,10 +66,10 @@ def get_cache_dir(child_dir: str = ''): def download_cached_file( - url: Union[str, List[str], Tuple[str, str]], - check_hash: bool = True, - progress: bool = False, - cache_dir: Optional[Union[str, Path]] = None, + url: Union[str, List[str], Tuple[str, str]], + check_hash: bool = True, + progress: bool = False, + cache_dir: Optional[Union[str, Path]] = None, ): if isinstance(url, (list, tuple)): url, filename = url @@ -102,9 +92,9 @@ def download_cached_file( def check_cached_file( - url: Union[str, List[str], Tuple[str, str]], - check_hash: bool = True, - cache_dir: Optional[Union[str, Path]] = None, + url: Union[str, List[str], Tuple[str, str]], + check_hash: bool = True, + cache_dir: Optional[Union[str, Path]] = None, ): if isinstance(url, (list, tuple)): url, filename = url @@ -121,7 +111,7 @@ def check_cached_file( if hash_prefix: with open(cached_file, 'rb') as f: hd = hashlib.sha256(f.read()).hexdigest() - if hd[: len(hash_prefix)] != hash_prefix: + if hd[:len(hash_prefix)] != hash_prefix: return False return True return False @@ -131,8 +121,7 @@ def has_hf_hub(necessary: bool = False): if not _has_hf_hub and necessary: # if no HF Hub module installed, and it is necessary to continue, raise error raise RuntimeError( - 'Hugging Face hub model specified but package not installed. Run `pip install huggingface_hub`.' - ) + 'Hugging Face hub model specified but package not installed. Run `pip install huggingface_hub`.') return _has_hf_hub @@ -152,9 +141,9 @@ def load_cfg_from_json(json_file: Union[str, Path]): def download_from_hf( - model_id: str, - filename: str, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + filename: str, + cache_dir: Optional[Union[str, Path]] = None, ): hf_model_id, hf_revision = hf_split(model_id) return hf_hub_download( @@ -166,8 +155,8 @@ def download_from_hf( def _parse_model_cfg( - cfg: Dict[str, Any], - extra_fields: Dict[str, Any], + cfg: Dict[str, Any], + extra_fields: Dict[str, Any], ) -> Tuple[Dict[str, Any], str, Dict[str, Any]]: """""" # legacy "single‑dict" → split @@ -178,7 +167,7 @@ def _parse_model_cfg( "num_features": pretrained_cfg.pop("num_features", None), "pretrained_cfg": pretrained_cfg, } - if "labels" in pretrained_cfg: # rename ‑‑> label_names + if "labels" in pretrained_cfg: # rename ‑‑> label_names pretrained_cfg["label_names"] = pretrained_cfg.pop("labels") pretrained_cfg = cfg["pretrained_cfg"] @@ -198,8 +187,8 @@ def _parse_model_cfg( def load_model_config_from_hf( - model_id: str, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + cache_dir: Optional[Union[str, Path]] = None, ): """Original HF‑Hub loader (unchanged download, shared parsing).""" assert has_hf_hub(True) @@ -209,7 +198,7 @@ def load_model_config_from_hf( def load_model_config_from_path( - model_path: Union[str, Path], + model_path: Union[str, Path], ): """Load from ``/config.json`` on the local filesystem.""" model_path = Path(model_path) @@ -222,10 +211,10 @@ def load_model_config_from_path( def load_state_dict_from_hf( - model_id: str, - filename: str = HF_WEIGHTS_NAME, - weights_only: bool = False, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + filename: str = HF_WEIGHTS_NAME, + weights_only: bool = False, + cache_dir: Optional[Union[str, Path]] = None, ): assert has_hf_hub(True) hf_model_id, hf_revision = hf_split(model_id) @@ -242,8 +231,7 @@ def load_state_dict_from_hf( ) _logger.info( f"[{model_id}] Safe alternative available for '{filename}' " - f"(as '{safe_filename}'). Loading weights using safetensors." - ) + f"(as '{safe_filename}'). Loading weights using safetensors.") return safetensors.torch.load_file(cached_safe_file, device="cpu") except EntryNotFoundError: pass @@ -275,10 +263,9 @@ def load_state_dict_from_hf( ) _EXT_PRIORITY = ('.safetensors', '.pth', '.pth.tar', '.bin') - def load_state_dict_from_path( - path: str, - weights_only: bool = False, + path: str, + weights_only: bool = False, ): found_file = None for fname in _PREFERRED_FILES: @@ -293,7 +280,10 @@ def load_state_dict_from_path( files = sorted(path.glob(f"*{ext}")) if files: if len(files) > 1: - logging.warning(f"Multiple {ext} checkpoints in {path}: {names}. " f"Using '{files[0].name}'.") + logging.warning( + f"Multiple {ext} checkpoints in {path}: {names}. " + f"Using '{files[0].name}'." + ) found_file = files[0] if not found_file: @@ -307,10 +297,10 @@ def load_state_dict_from_path( def load_custom_from_hf( - model_id: str, - filename: str, - model: torch.nn.Module, - cache_dir: Optional[Union[str, Path]] = None, + model_id: str, + filename: str, + model: torch.nn.Module, + cache_dir: Optional[Union[str, Path]] = None, ): assert has_hf_hub(True) hf_model_id, hf_revision = hf_split(model_id) @@ -324,7 +314,10 @@ def load_custom_from_hf( def save_config_for_hf( - model: torch.nn.Module, config_path: str, model_config: Optional[dict] = None, model_args: Optional[dict] = None + model: torch.nn.Module, + config_path: str, + model_config: Optional[dict] = None, + model_args: Optional[dict] = None ): model_config = model_config or {} hf_config = {} @@ -343,8 +336,7 @@ def save_config_for_hf( if 'labels' in model_config: _logger.warning( "'labels' as a config field for is deprecated. Please use 'label_names' and 'label_descriptions'." - " Renaming provided 'labels' field to 'label_names'." - ) + " Renaming provided 'labels' field to 'label_names'.") model_config.setdefault('label_names', model_config.pop('labels')) label_names = model_config.pop('label_names', None) @@ -371,11 +363,11 @@ def save_config_for_hf( def save_for_hf( - model: torch.nn.Module, - save_directory: str, - model_config: Optional[dict] = None, - model_args: Optional[dict] = None, - safe_serialization: Union[bool, Literal["both"]] = False, + model: torch.nn.Module, + save_directory: str, + model_config: Optional[dict] = None, + model_args: Optional[dict] = None, + safe_serialization: Union[bool, Literal["both"]] = False, ): assert has_hf_hub(True) save_directory = Path(save_directory) @@ -399,18 +391,18 @@ def save_for_hf( def push_to_hf_hub( - model: torch.nn.Module, - repo_id: str, - commit_message: str = 'Add model', - token: Optional[str] = None, - revision: Optional[str] = None, - private: bool = False, - create_pr: bool = False, - model_config: Optional[dict] = None, - model_card: Optional[dict] = None, - model_args: Optional[dict] = None, - task_name: str = 'image-classification', - safe_serialization: Union[bool, Literal["both"]] = 'both', + model: torch.nn.Module, + repo_id: str, + commit_message: str = 'Add model', + token: Optional[str] = None, + revision: Optional[str] = None, + private: bool = False, + create_pr: bool = False, + model_config: Optional[dict] = None, + model_card: Optional[dict] = None, + model_args: Optional[dict] = None, + task_name: str = 'image-classification', + safe_serialization: Union[bool, Literal["both"]] = 'both', ): """ Arguments: @@ -460,9 +452,9 @@ def push_to_hf_hub( def generate_readme( - model_card: dict, - model_name: str, - task_name: str = 'image-classification', + model_card: dict, + model_name: str, + task_name: str = 'image-classification', ): tags = model_card.get('tags', None) or [task_name, 'timm', 'transformers'] readme_text = "---\n" From 288e5b549cff970deadd3512f359cc3024286beb Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Mon, 22 Sep 2025 21:47:30 +0200 Subject: [PATCH 4/9] Undoing changes to cspnet.py --- timm/models/cspnet.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/timm/models/cspnet.py b/timm/models/cspnet.py index 45228635d9..6de3b354ee 100644 --- a/timm/models/cspnet.py +++ b/timm/models/cspnet.py @@ -22,7 +22,6 @@ from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from timm.layers import ClassifierHead, ConvNormAct, DropPath, calculate_drop_path_rates, get_attn, create_act_layer, make_divisible from ._builder import build_model_with_cfg -from ._hub import _get_license_from_hf_hub from ._manipulate import named_apply, MATCH_PREV_GROUP from ._registry import register_model, generate_default_cfgs @@ -1012,25 +1011,22 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.887, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1.conv', 'classifier': 'head.fc', - 'license': _get_license_from_hf_hub(kwargs.pop('model_id', None), kwargs.get('hf_hub_id')), **kwargs } + default_cfgs = generate_default_cfgs({ 'cspresnet50.ra_in1k': _cfg( hf_hub_id='timm/', - model_id='cspresnet50.ra_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/cspresnet50_ra-d3e8d487.pth'), 'cspresnet50d.untrained': _cfg(), 'cspresnet50w.untrained': _cfg(), 'cspresnext50.ra_in1k': _cfg( hf_hub_id='timm/', - model_id='cspresnext50.ra_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/cspresnext50_ra_224-648b4713.pth', ), 'cspdarknet53.ra_in1k': _cfg( hf_hub_id='timm/', - model_id='cspdarknet53.ra_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/cspdarknet53_ra_256-d05c7c21.pth'), 'darknet17.untrained': _cfg(), @@ -1038,58 +1034,48 @@ def _cfg(url='', **kwargs): 'sedarknet21.untrained': _cfg(), 'darknet53.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='darknet53.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/darknet53_256_c2ns-3aeff817.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=1.0), 'darknetaa53.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='darknetaa53.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/darknetaa53_c2ns-5c28ec8a.pth', test_input_size=(3, 288, 288), test_crop_pct=1.0), 'cs3darknet_s.untrained': _cfg(interpolation='bicubic'), 'cs3darknet_m.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3darknet_m.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_m_c2ns-43f06604.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95, ), 'cs3darknet_l.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3darknet_l.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_l_c2ns-16220c5d.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3darknet_x.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3darknet_x.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_x_c2ns-4e4490aa.pth', interpolation='bicubic', crop_pct=0.95, test_input_size=(3, 288, 288), test_crop_pct=1.0), 'cs3darknet_focus_s.ra4_e3600_r256_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3darknet_focus_s.ra4_e3600_r256_in1k', mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5), interpolation='bicubic', test_input_size=(3, 320, 320), test_crop_pct=1.0), 'cs3darknet_focus_m.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3darknet_focus_m.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_focus_m_c2ns-e23bed41.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3darknet_focus_l.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3darknet_focus_l.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3darknet_focus_l_c2ns-65ef8888.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3darknet_focus_x.untrained': _cfg(interpolation='bicubic'), 'cs3sedarknet_l.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3sedarknet_l.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3sedarknet_l_c2ns-e8d1dc13.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=0.95), 'cs3sedarknet_x.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3sedarknet_x.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3sedarknet_x_c2ns-b4d0abc0.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=1.0), @@ -1097,12 +1083,10 @@ def _cfg(url='', **kwargs): 'cs3edgenet_x.c2_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3edgenet_x.c2_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3edgenet_x_c2-2e1610a9.pth', interpolation='bicubic', test_input_size=(3, 288, 288), test_crop_pct=1.0), 'cs3se_edgenet_x.c2ns_in1k': _cfg( hf_hub_id='timm/', - model_id='cs3se_edgenet_x.c2ns_in1k', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/cs3se_edgenet_x_c2ns-76f8e3ac.pth', interpolation='bicubic', crop_pct=0.95, test_input_size=(3, 320, 320), test_crop_pct=1.0), }) @@ -1220,4 +1204,4 @@ def cs3edgenet_x(pretrained=False, **kwargs) -> CspNet: @register_model def cs3se_edgenet_x(pretrained=False, **kwargs) -> CspNet: - return _create_cspnet('cs3se_edgenet_x', pretrained=pretrained, **kwargs) + return _create_cspnet('cs3se_edgenet_x', pretrained=pretrained, **kwargs) \ No newline at end of file From 25c4790a4574169b2012f5832de06805e1d3fc57 Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Mon, 22 Sep 2025 21:52:15 +0200 Subject: [PATCH 5/9] Adding new approach --- timm/models/_hub.py | 22 +++++++++++----------- timm/models/_pretrained.py | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index ef9bf842c0..d7186ed460 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -535,17 +535,17 @@ def _get_safe_alternatives(filename: str) -> Iterable[str]: yield filename[:-4] + ".safetensors" -def _get_license_from_hf_hub(model_id: str | None, hf_hub_id: str | None) -> str | None: +def _get_license_from_hf_hub(hf_hub_id: str | None) -> str | None: """Retrieve license information for a model from Hugging Face Hub. Fetches the license field from the model card metadata on Hugging Face Hub - for the specified model. Returns None if the model is not found, if - huggingface_hub is not installed, or if the model is marked as "untrained". + for the specified model. This function is called lazily when the license + attribute is accessed on PretrainedCfg objects that don't have an explicit + license set. Args: - model_id: The model identifier/name. In the case of None we assume an untrained model. - hf_hub_id: The Hugging Face Hub organization/user ID. If it is None, - we will return None as we cannot infer the license terms. + hf_hub_id: The Hugging Face Hub model ID (e.g., 'organization/model'). + If None or empty, returns None as license cannot be determined. Returns: The license string in lowercase if found, None otherwise. @@ -559,17 +559,17 @@ def _get_license_from_hf_hub(model_id: str | None, hf_hub_id: str | None) -> str _logger.warning(msg=msg) return None - if not (model_id and hf_hub_id): + if hf_hub_id is None or hf_hub_id == "timm/": return None - repo_id: str = hf_hub_id + model_id - try: - info = model_info(repo_id=repo_id) + info = model_info(repo_id=hf_hub_id) except RepositoryNotFoundError: # TODO: any wish what happens here? @rwightman - print(repo_id) + return None + + except Exception as _: return None license = info.card_data.get("license").lower() if info.card_data else None diff --git a/timm/models/_pretrained.py b/timm/models/_pretrained.py index 2938f8fe71..c22271318e 100644 --- a/timm/models/_pretrained.py +++ b/timm/models/_pretrained.py @@ -58,6 +58,20 @@ class PretrainedCfg: def has_weights(self): return self.url or self.file or self.hf_hub_id + def __getattribute__(self, name): + if name == 'license': # Intercept license access to set it in case it was not set anywhere else. + license_value = super().__getattribute__('license') + + if license_value is None: + from ._hub import _get_license_from_hf_hub + license_value = _get_license_from_hf_hub(hf_hub_id=self.hf_hub_id) + + self.license = license_value + + return license_value + + return super().__getattribute__(name) + def to_dict(self, remove_source=False, remove_null=True): return filter_pretrained_cfg( asdict(self), From 1c24c176652b8fa31a241cb35c74b83bfb0e1fc1 Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Tue, 23 Sep 2025 11:59:13 +0200 Subject: [PATCH 6/9] Revert "Adding new approach" This reverts commit 166a524850b84e4731b810d02862c3d059299e51. --- timm/models/_hub.py | 22 +++++++++++----------- timm/models/_pretrained.py | 14 -------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index d7186ed460..ef9bf842c0 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -535,17 +535,17 @@ def _get_safe_alternatives(filename: str) -> Iterable[str]: yield filename[:-4] + ".safetensors" -def _get_license_from_hf_hub(hf_hub_id: str | None) -> str | None: +def _get_license_from_hf_hub(model_id: str | None, hf_hub_id: str | None) -> str | None: """Retrieve license information for a model from Hugging Face Hub. Fetches the license field from the model card metadata on Hugging Face Hub - for the specified model. This function is called lazily when the license - attribute is accessed on PretrainedCfg objects that don't have an explicit - license set. + for the specified model. Returns None if the model is not found, if + huggingface_hub is not installed, or if the model is marked as "untrained". Args: - hf_hub_id: The Hugging Face Hub model ID (e.g., 'organization/model'). - If None or empty, returns None as license cannot be determined. + model_id: The model identifier/name. In the case of None we assume an untrained model. + hf_hub_id: The Hugging Face Hub organization/user ID. If it is None, + we will return None as we cannot infer the license terms. Returns: The license string in lowercase if found, None otherwise. @@ -559,17 +559,17 @@ def _get_license_from_hf_hub(hf_hub_id: str | None) -> str | None: _logger.warning(msg=msg) return None - if hf_hub_id is None or hf_hub_id == "timm/": + if not (model_id and hf_hub_id): return None + repo_id: str = hf_hub_id + model_id + try: - info = model_info(repo_id=hf_hub_id) + info = model_info(repo_id=repo_id) except RepositoryNotFoundError: # TODO: any wish what happens here? @rwightman - return None - - except Exception as _: + print(repo_id) return None license = info.card_data.get("license").lower() if info.card_data else None diff --git a/timm/models/_pretrained.py b/timm/models/_pretrained.py index c22271318e..2938f8fe71 100644 --- a/timm/models/_pretrained.py +++ b/timm/models/_pretrained.py @@ -58,20 +58,6 @@ class PretrainedCfg: def has_weights(self): return self.url or self.file or self.hf_hub_id - def __getattribute__(self, name): - if name == 'license': # Intercept license access to set it in case it was not set anywhere else. - license_value = super().__getattribute__('license') - - if license_value is None: - from ._hub import _get_license_from_hf_hub - license_value = _get_license_from_hf_hub(hf_hub_id=self.hf_hub_id) - - self.license = license_value - - return license_value - - return super().__getattribute__(name) - def to_dict(self, remove_source=False, remove_null=True): return filter_pretrained_cfg( asdict(self), From e6225c8bbd5c45d9f00f7b744ebab6e0febee426 Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Wed, 24 Sep 2025 22:53:37 +0200 Subject: [PATCH 7/9] Updating licenses --- timm/models/_hub.py | 9 +++++++-- timm/models/beit.py | 1 + timm/models/byoanet.py | 2 +- timm/models/byobnet.py | 23 +++++++++++++++++++++++ timm/models/cait.py | 1 + timm/models/coat.py | 3 ++- timm/models/convit.py | 2 +- timm/models/convmixer.py | 4 ++-- timm/models/convnext.py | 2 +- timm/models/crossvit.py | 1 + timm/models/cspnet.py | 4 ++-- timm/models/davit.py | 1 + timm/models/deit.py | 1 + timm/models/densenet.py | 3 ++- timm/models/dla.py | 6 +++--- timm/models/dpn.py | 2 +- timm/models/edgenext.py | 1 + timm/models/efficientformer.py | 1 + timm/models/efficientformer_v2.py | 1 + timm/models/efficientnet.py | 2 +- timm/models/efficientvit_mit.py | 1 + timm/models/efficientvit_msra.py | 1 + timm/models/eva.py | 2 +- timm/models/fasternet.py | 1 + timm/models/fastvit.py | 9 +++++---- timm/models/gcvit.py | 1 + timm/models/ghostnet.py | 1 + timm/models/hardcorenas.py | 1 + timm/models/hgnet.py | 1 + timm/models/hiera.py | 1 + timm/models/hieradet_sam2.py | 1 + timm/models/hrnet.py | 5 +++-- timm/models/inception_next.py | 1 + timm/models/inception_resnet_v2.py | 2 ++ timm/models/inception_v3.py | 4 ++-- timm/models/inception_v4.py | 1 + timm/models/levit.py | 1 + timm/models/mambaout.py | 1 + timm/models/maxxvit.py | 2 +- timm/models/metaformer.py | 1 + timm/models/mlp_mixer.py | 1 + timm/models/mobilenetv3.py | 2 +- timm/models/mobilenetv5.py | 3 ++- timm/models/mobilevit.py | 3 ++- timm/models/mvitv2.py | 1 + timm/models/nasnet.py | 1 + timm/models/nest.py | 1 + timm/models/nextvit.py | 1 + timm/models/nfnet.py | 4 ++-- timm/models/pit.py | 1 + timm/models/pnasnet.py | 1 + timm/models/pvt_v2.py | 1 + timm/models/rdnet.py | 1 + timm/models/regnet.py | 2 +- timm/models/repghost.py | 1 + timm/models/repvit.py | 1 + timm/models/res2net.py | 1 + timm/models/resnest.py | 1 + timm/models/resnet.py | 1 + timm/models/resnetv2.py | 1 + timm/models/selecsls.py | 1 + timm/models/sequencer.py | 1 + timm/models/shvit.py | 1 + timm/models/sknet.py | 1 + timm/models/starnet.py | 4 ++-- timm/models/swiftformer.py | 1 + timm/models/swin_transformer_v2_cr.py | 1 + timm/models/tiny_vit.py | 1 + timm/models/tnt.py | 1 + timm/models/tresnet.py | 1 + timm/models/twins.py | 1 + timm/models/vgg.py | 1 + timm/models/visformer.py | 1 + timm/models/vision_transformer.py | 6 ++++++ timm/models/vision_transformer_hybrid.py | 2 ++ timm/models/vision_transformer_relpos.py | 1 + timm/models/volo.py | 1 + timm/models/vovnet.py | 3 ++- timm/models/xception_aligned.py | 2 +- timm/models/xcit.py | 2 +- 80 files changed, 133 insertions(+), 37 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index ef9bf842c0..c2b1ec823b 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -568,8 +568,13 @@ def _get_license_from_hf_hub(model_id: str | None, hf_hub_id: str | None) -> str info = model_info(repo_id=repo_id) except RepositoryNotFoundError: - # TODO: any wish what happens here? @rwightman - print(repo_id) + msg = f"Repository {repo_id} was not found. Manual inspection of license needed." + _logger.warning(msg=msg) + return None + + except Exception as _: + msg = f"Error for {repo_id}. Manual inspection of license needed." + _logger.warning(msg=msg) return None license = info.card_data.get("license").lower() if info.card_data else None diff --git a/timm/models/beit.py b/timm/models/beit.py index 6c241edf35..baf4d11725 100644 --- a/timm/models/beit.py +++ b/timm/models/beit.py @@ -773,6 +773,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': (0.5, 0.5, 0.5), 'std': (0.5, 0.5, 0.5), 'first_conv': 'patch_embed.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/byoanet.py b/timm/models/byoanet.py index f5af4fd113..3f79211534 100644 --- a/timm/models/byoanet.py +++ b/timm/models/byoanet.py @@ -297,7 +297,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 0.95, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1.conv', 'classifier': 'head.fc', - 'fixed_input_size': False, 'min_input_size': (3, 224, 224), + 'fixed_input_size': False, 'min_input_size': (3, 224, 224), 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/byobnet.py b/timm/models/byobnet.py index 60a443d3d8..be722b46c6 100644 --- a/timm/models/byobnet.py +++ b/timm/models/byobnet.py @@ -2432,6 +2432,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } @@ -2451,6 +2452,7 @@ def _cfgr(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 0.9, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1.conv', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } @@ -2604,26 +2606,31 @@ def _cfgr(url: str = '', **kwargs) -> Dict[str, Any]: hf_hub_id='timm/', crop_pct=0.875, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), + license='other', ), 'mobileone_s1.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), + license='other', ), 'mobileone_s2.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), + license='other', ), 'mobileone_s3.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), + license='other', ), 'mobileone_s4.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), + license='other', ), # original attention pool head variants @@ -2632,48 +2639,56 @@ def _cfgr(url: str = '', **kwargs) -> Dict[str, Any]: num_classes=1024, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 224, 224), pool_size=(7, 7), classifier='head.proj', + license='mit', ), 'resnet101_clip.openai': _cfgr( hf_hub_id='timm/', num_classes=512, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 224, 224), pool_size=(7, 7), classifier='head.proj', + license='mit', ), 'resnet50x4_clip.openai': _cfgr( hf_hub_id='timm/', num_classes=640, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 288, 288), pool_size=(9, 9), classifier='head.proj', + license='mit', ), 'resnet50x16_clip.openai': _cfgr( hf_hub_id='timm/', num_classes=768, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 384, 384), pool_size=(12, 12), classifier='head.proj', + license='mit', ), 'resnet50x64_clip.openai': _cfgr( hf_hub_id='timm/', num_classes=1024, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 448, 448), pool_size=(14, 14), classifier='head.proj', + license='mit', ), 'resnet50_clip.cc12m': _cfgr( hf_hub_id='timm/', num_classes=1024, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 224, 224), pool_size=(7, 7), classifier='head.proj', + license='mit', ), 'resnet50_clip.yfcc15m': _cfgr( hf_hub_id='timm/', num_classes=1024, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 224, 224), pool_size=(7, 7), classifier='head.proj', + license='mit', ), 'resnet101_clip.yfcc15m': _cfgr( hf_hub_id='timm/', num_classes=512, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, fixed_input_size=True, input_size=(3, 224, 224), pool_size=(7, 7), classifier='head.proj', + license='mit', ), # avg-pool w/ optional standard classifier head variants @@ -2681,41 +2696,49 @@ def _cfgr(url: str = '', **kwargs) -> Dict[str, Any]: hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 224, 224), pool_size=(7, 7), + license='mit', ), 'resnet101_clip_gap.openai': _cfgr( hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 224, 224), pool_size=(7, 7), + license='mit', ), 'resnet50x4_clip_gap.openai': _cfgr( hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 288, 288), pool_size=(9, 9), + license='mit', ), 'resnet50x16_clip_gap.openai': _cfgr( hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 384, 384), pool_size=(12, 12), + license='mit', ), 'resnet50x64_clip_gap.openai': _cfgr( hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 448, 448), pool_size=(14, 14), + license='mit', ), 'resnet50_clip_gap.cc12m': _cfgr( hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 224, 224), pool_size=(7, 7), + license='mit', ), 'resnet50_clip_gap.yfcc15m': _cfgr( hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 224, 224), pool_size=(7, 7), + license='mit', ), 'resnet101_clip_gap.yfcc15m': _cfgr( hf_hub_id='timm/', num_classes=0, mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 224, 224), pool_size=(7, 7), + license='mit', ), 'resnet50_mlp.untrained': _cfgr( diff --git a/timm/models/cait.py b/timm/models/cait.py index b484ef4d8c..315ab98931 100644 --- a/timm/models/cait.py +++ b/timm/models/cait.py @@ -508,6 +508,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 1.0, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/coat.py b/timm/models/coat.py index 770cf18fb7..f239c31ea7 100644 --- a/timm/models/coat.py +++ b/timm/models/coat.py @@ -759,6 +759,7 @@ def _cfg_coat(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed1.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } @@ -839,4 +840,4 @@ def coat_lite_medium_384(pretrained=False, **kwargs) -> CoaT: model_cfg = dict( img_size=384, patch_size=4, embed_dims=[128, 256, 320, 512], serial_depths=[3, 6, 10, 8]) model = _create_coat('coat_lite_medium_384', pretrained=pretrained, **dict(model_cfg, **kwargs)) - return model \ No newline at end of file + return model diff --git a/timm/models/convit.py b/timm/models/convit.py index ece9ad0895..272649c656 100644 --- a/timm/models/convit.py +++ b/timm/models/convit.py @@ -420,7 +420,7 @@ def _cfg(url='', **kwargs): 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': None, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'fixed_input_size': True, - 'first_conv': 'patch_embed.proj', 'classifier': 'head', + 'first_conv': 'patch_embed.proj', 'classifier': 'head', 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/convmixer.py b/timm/models/convmixer.py index 55978f67f8..bad04bd154 100644 --- a/timm/models/convmixer.py +++ b/timm/models/convmixer.py @@ -118,7 +118,7 @@ def _cfg(url='', **kwargs): 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': None, 'crop_pct': .96, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'classifier': 'head', - 'first_conv': 'stem.0', + 'first_conv': 'stem.0', 'license': 'mit', **kwargs } @@ -146,4 +146,4 @@ def convmixer_768_32(pretrained=False, **kwargs) -> ConvMixer: @register_model def convmixer_1024_20_ks9_p14(pretrained=False, **kwargs) -> ConvMixer: model_args = dict(dim=1024, depth=20, kernel_size=9, patch_size=14, **kwargs) - return _create_convmixer('convmixer_1024_20_ks9_p14', pretrained, **model_args) \ No newline at end of file + return _create_convmixer('convmixer_1024_20_ks9_p14', pretrained, **model_args) diff --git a/timm/models/convnext.py b/timm/models/convnext.py index c801f7c887..c62a488819 100644 --- a/timm/models/convnext.py +++ b/timm/models/convnext.py @@ -711,7 +711,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.0', 'classifier': 'head.fc', - **kwargs + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/crossvit.py b/timm/models/crossvit.py index a19489b358..a0cb5c4d20 100644 --- a/timm/models/crossvit.py +++ b/timm/models/crossvit.py @@ -519,6 +519,7 @@ def _cfg(url='', **kwargs): 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'fixed_input_size': True, 'first_conv': ('patch_embed.0.proj', 'patch_embed.1.proj'), 'classifier': ('head.0', 'head.1'), + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/cspnet.py b/timm/models/cspnet.py index 6de3b354ee..5cf7fff03d 100644 --- a/timm/models/cspnet.py +++ b/timm/models/cspnet.py @@ -1010,7 +1010,7 @@ def _cfg(url='', **kwargs): 'num_classes': 1000, 'input_size': (3, 256, 256), 'pool_size': (8, 8), 'crop_pct': 0.887, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, - 'first_conv': 'stem.conv1.conv', 'classifier': 'head.fc', + 'first_conv': 'stem.conv1.conv', 'classifier': 'head.fc', 'license': 'apache-2.0', **kwargs } @@ -1204,4 +1204,4 @@ def cs3edgenet_x(pretrained=False, **kwargs) -> CspNet: @register_model def cs3se_edgenet_x(pretrained=False, **kwargs) -> CspNet: - return _create_cspnet('cs3se_edgenet_x', pretrained=pretrained, **kwargs) \ No newline at end of file + return _create_cspnet('cs3se_edgenet_x', pretrained=pretrained, **kwargs) diff --git a/timm/models/davit.py b/timm/models/davit.py index f030a43a07..4608b2365d 100644 --- a/timm/models/davit.py +++ b/timm/models/davit.py @@ -870,6 +870,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.95, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/deit.py b/timm/models/deit.py index ed8a6dec1d..237c59546c 100644 --- a/timm/models/deit.py +++ b/timm/models/deit.py @@ -141,6 +141,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/densenet.py b/timm/models/densenet.py index a09da46d23..b87b6a1f74 100644 --- a/timm/models/densenet.py +++ b/timm/models/densenet.py @@ -488,7 +488,8 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, - 'first_conv': 'features.conv0', 'classifier': 'classifier', **kwargs, + 'first_conv': 'features.conv0', 'classifier': 'classifier', 'license': 'apache-2.0', + **kwargs, } diff --git a/timm/models/dla.py b/timm/models/dla.py index 2763686dbf..0cc15fae15 100644 --- a/timm/models/dla.py +++ b/timm/models/dla.py @@ -492,7 +492,7 @@ def _cfg(url='', **kwargs): 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, - 'first_conv': 'base_layer.0', 'classifier': 'fc', + 'first_conv': 'base_layer.0', 'classifier': 'fc', 'license': 'bsd-3-clause', **kwargs } @@ -508,8 +508,8 @@ def _cfg(url='', **kwargs): 'dla102x.in1k': _cfg(hf_hub_id='timm/'), 'dla102x2.in1k': _cfg(hf_hub_id='timm/'), 'dla169.in1k': _cfg(hf_hub_id='timm/'), - 'dla60_res2net.in1k': _cfg(hf_hub_id='timm/'), - 'dla60_res2next.in1k': _cfg(hf_hub_id='timm/'), + 'dla60_res2net.in1k': _cfg(hf_hub_id='timm/', license='unknown'), + 'dla60_res2next.in1k': _cfg(hf_hub_id='timm/', license='unknown'), }) diff --git a/timm/models/dpn.py b/timm/models/dpn.py index 759658b75d..9e64f113a3 100644 --- a/timm/models/dpn.py +++ b/timm/models/dpn.py @@ -330,7 +330,7 @@ def _cfg(url='', **kwargs): 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DPN_MEAN, 'std': IMAGENET_DPN_STD, - 'first_conv': 'features.conv1_1.conv', 'classifier': 'classifier', + 'first_conv': 'features.conv1_1.conv', 'classifier': 'classifier', 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/edgenext.py b/timm/models/edgenext.py index a83ea6ddf4..bc4e6724c0 100644 --- a/timm/models/edgenext.py +++ b/timm/models/edgenext.py @@ -621,6 +621,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.9, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.0', 'classifier': 'head.fc', + 'license': 'mit', **kwargs } diff --git a/timm/models/efficientformer.py b/timm/models/efficientformer.py index 7e140da581..622592e4da 100644 --- a/timm/models/efficientformer.py +++ b/timm/models/efficientformer.py @@ -625,6 +625,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .95, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1', 'classifier': ('head', 'head_dist'), + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/efficientformer_v2.py b/timm/models/efficientformer_v2.py index 92fbdaf14a..4e621d95df 100644 --- a/timm/models/efficientformer_v2.py +++ b/timm/models/efficientformer_v2.py @@ -806,6 +806,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .95, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'classifier': ('head', 'head_dist'), 'first_conv': 'stem.conv1.conv', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/efficientnet.py b/timm/models/efficientnet.py index edc568335e..e48e284fbe 100644 --- a/timm/models/efficientnet.py +++ b/timm/models/efficientnet.py @@ -1324,7 +1324,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv_stem', 'classifier': 'classifier', - **kwargs + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/efficientvit_mit.py b/timm/models/efficientvit_mit.py index 3cae78d897..05a9f50970 100644 --- a/timm/models/efficientvit_mit.py +++ b/timm/models/efficientvit_mit.py @@ -1083,6 +1083,7 @@ def _cfg(url='', **kwargs): 'first_conv': 'stem.in_conv.conv', 'classifier': 'head.classifier.4', 'crop_pct': 0.95, + 'license': 'apache-2.0', 'input_size': (3, 224, 224), 'pool_size': (7, 7), **kwargs, diff --git a/timm/models/efficientvit_msra.py b/timm/models/efficientvit_msra.py index 497e984726..a445d680fd 100644 --- a/timm/models/efficientvit_msra.py +++ b/timm/models/efficientvit_msra.py @@ -672,6 +672,7 @@ def _cfg(url='', **kwargs): 'classifier': 'head.linear', 'fixed_input_size': True, 'pool_size': (4, 4), + 'license': 'mit', **kwargs, } diff --git a/timm/models/eva.py b/timm/models/eva.py index 117a76b5c1..da5c97d144 100644 --- a/timm/models/eva.py +++ b/timm/models/eva.py @@ -1285,7 +1285,7 @@ def _pe_cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 1.0, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': (0.5, 0.5, 0.5), 'std': (0.5, 0.5, 0.5), 'first_conv': 'patch_embed.proj', 'classifier': 'head', - 'license': 'custom', **kwargs + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/fasternet.py b/timm/models/fasternet.py index f956f70ac4..0d3e117219 100644 --- a/timm/models/fasternet.py +++ b/timm/models/fasternet.py @@ -426,6 +426,7 @@ def _cfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'paper_ids': 'arXiv:2303.03667', 'paper_name': "Run, Don't Walk: Chasing Higher FLOPS for Faster Neural Networks", 'origin_url': 'https://github.com/JierunChen/FasterNet', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/fastvit.py b/timm/models/fastvit.py index bef5ec8b61..c0d39e6dbf 100644 --- a/timm/models/fastvit.py +++ b/timm/models/fastvit.py @@ -1431,6 +1431,7 @@ def _cfg(url="", **kwargs): "crop_pct": 0.9, "interpolation": "bicubic", "mean": IMAGENET_DEFAULT_MEAN, + "license": "other", "std": IMAGENET_DEFAULT_STD, 'first_conv': ('stem.0.conv_kxk.0.conv', 'stem.0.conv_scale.conv'), "classifier": "head.fc", @@ -1481,21 +1482,21 @@ def _cfg(url="", **kwargs): url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_s0.pt', crop_pct=0.95, num_classes=512, # CLIP proj dim - mean=(0., 0., 0.), std=(1., 1., 1.) + mean=(0., 0., 0.), std=(1., 1., 1.), license=None, ), "fastvit_mci1.apple_mclip": _cfg( hf_hub_id='apple/mobileclip_s1_timm', url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_s1.pt', crop_pct=0.95, num_classes=512, # CLIP proj dim - mean=(0., 0., 0.), std=(1., 1., 1.) + mean=(0., 0., 0.), std=(1., 1., 1.), license=None, ), "fastvit_mci2.apple_mclip": _cfg( hf_hub_id='apple/mobileclip_s2_timm', url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_s2.pt', crop_pct=0.95, num_classes=512, # CLIP proj dim - mean=(0., 0., 0.), std=(1., 1., 1.) + mean=(0., 0., 0.), std=(1., 1., 1.), license=None, ), "fastvit_mci0.apple_mclip2_dfndr2b": _cfg( @@ -1803,4 +1804,4 @@ def fastvit_mci4(pretrained=False, **kwargs): ) model = _create_fastvit('fastvit_mci4', pretrained=pretrained, **dict(model_args, **kwargs)) - return model \ No newline at end of file + return model diff --git a/timm/models/gcvit.py b/timm/models/gcvit.py index 2533ed949c..1fadffec0d 100644 --- a/timm/models/gcvit.py +++ b/timm/models/gcvit.py @@ -615,6 +615,7 @@ def _cfg(url='', **kwargs): 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1', 'classifier': 'head.fc', 'fixed_input_size': True, + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/ghostnet.py b/timm/models/ghostnet.py index 53d988ac96..eb2e9d5806 100644 --- a/timm/models/ghostnet.py +++ b/timm/models/ghostnet.py @@ -911,6 +911,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv_stem', 'classifier': 'classifier', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/hardcorenas.py b/timm/models/hardcorenas.py index 459c1a3db8..491f7c0367 100644 --- a/timm/models/hardcorenas.py +++ b/timm/models/hardcorenas.py @@ -58,6 +58,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv_stem', 'classifier': 'classifier', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/hgnet.py b/timm/models/hgnet.py index 927b2c4dc6..dadda65340 100644 --- a/timm/models/hgnet.py +++ b/timm/models/hgnet.py @@ -749,6 +749,7 @@ def _cfg(url='', **kwargs): 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'classifier': 'head.fc', 'first_conv': 'stem.stem1.conv', 'test_crop_pct': 1.0, 'test_input_size': (3, 288, 288), + 'license': 'apache-2.0', **kwargs, } diff --git a/timm/models/hiera.py b/timm/models/hiera.py index 81342a2fef..b078719e10 100644 --- a/timm/models/hiera.py +++ b/timm/models/hiera.py @@ -844,6 +844,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/hieradet_sam2.py b/timm/models/hieradet_sam2.py index 33bdcbf994..269aafb2fc 100644 --- a/timm/models/hieradet_sam2.py +++ b/timm/models/hieradet_sam2.py @@ -567,6 +567,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 1.0, 'interpolation': 'bicubic', 'min_input_size': (3, 224, 224), 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/hrnet.py b/timm/models/hrnet.py index 0a7734cd94..89cc2eeaec 100644 --- a/timm/models/hrnet.py +++ b/timm/models/hrnet.py @@ -928,14 +928,15 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv1', 'classifier': 'classifier', + 'license': 'mit', **kwargs } default_cfgs = generate_default_cfgs({ - 'hrnet_w18_small.gluon_in1k': _cfg(hf_hub_id='timm/', interpolation='bicubic'), + 'hrnet_w18_small.gluon_in1k': _cfg(hf_hub_id='timm/', interpolation='bicubic', license='apache-2.0'), 'hrnet_w18_small.ms_in1k': _cfg(hf_hub_id='timm/'), - 'hrnet_w18_small_v2.gluon_in1k': _cfg(hf_hub_id='timm/', interpolation='bicubic'), + 'hrnet_w18_small_v2.gluon_in1k': _cfg(hf_hub_id='timm/', interpolation='bicubic', license='apache-2.0'), 'hrnet_w18_small_v2.ms_in1k': _cfg(hf_hub_id='timm/'), 'hrnet_w18.ms_aug_in1k': _cfg( hf_hub_id='timm/', diff --git a/timm/models/inception_next.py b/timm/models/inception_next.py index a2a2097458..418cd79a9f 100644 --- a/timm/models/inception_next.py +++ b/timm/models/inception_next.py @@ -445,6 +445,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.0', 'classifier': 'head.fc2', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/inception_resnet_v2.py b/timm/models/inception_resnet_v2.py index 0e27efebeb..9e56315329 100644 --- a/timm/models/inception_resnet_v2.py +++ b/timm/models/inception_resnet_v2.py @@ -366,6 +366,7 @@ def _create_inception_resnet_v2(variant, pretrained=False, **kwargs): 'crop_pct': 0.8975, 'interpolation': 'bicubic', 'mean': IMAGENET_INCEPTION_MEAN, 'std': IMAGENET_INCEPTION_STD, 'first_conv': 'conv2d_1a.conv', 'classifier': 'classif', + 'license': 'apache-2.0', }, # As per https://arxiv.org/abs/1705.07204 and # ported from http://download.tensorflow.org/models/ens_adv_inception_resnet_v2_2017_08_18.tar.gz @@ -375,6 +376,7 @@ def _create_inception_resnet_v2(variant, pretrained=False, **kwargs): 'crop_pct': 0.8975, 'interpolation': 'bicubic', 'mean': IMAGENET_INCEPTION_MEAN, 'std': IMAGENET_INCEPTION_STD, 'first_conv': 'conv2d_1a.conv', 'classifier': 'classif', + 'license': 'apache-2.0', } }) diff --git a/timm/models/inception_v3.py b/timm/models/inception_v3.py index fd073c72fd..648153b259 100644 --- a/timm/models/inception_v3.py +++ b/timm/models/inception_v3.py @@ -468,7 +468,7 @@ def _cfg(url='', **kwargs): 'num_classes': 1000, 'input_size': (3, 299, 299), 'pool_size': (8, 8), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_INCEPTION_MEAN, 'std': IMAGENET_INCEPTION_STD, - 'first_conv': 'Conv2d_1a_3x3.conv', 'classifier': 'fc', + 'first_conv': 'Conv2d_1a_3x3.conv', 'classifier': 'fc', 'license': 'apache-2.0', **kwargs } @@ -504,4 +504,4 @@ def inception_v3(pretrained=False, **kwargs) -> InceptionV3: 'tf_inception_v3': 'inception_v3.tf_in1k', 'adv_inception_v3': 'inception_v3.tf_adv_in1k', 'gluon_inception_v3': 'inception_v3.gluon_in1k', -}) \ No newline at end of file +}) diff --git a/timm/models/inception_v4.py b/timm/models/inception_v4.py index 9c06e1620a..150c51b474 100644 --- a/timm/models/inception_v4.py +++ b/timm/models/inception_v4.py @@ -434,6 +434,7 @@ def _create_inception_v4(variant, pretrained=False, **kwargs) -> InceptionV4: 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_INCEPTION_MEAN, 'std': IMAGENET_INCEPTION_STD, 'first_conv': 'features.0.conv', 'classifier': 'last_linear', + 'license': 'apache-2.0', } }) diff --git a/timm/models/levit.py b/timm/models/levit.py index affb48db8d..1463db4a68 100644 --- a/timm/models/levit.py +++ b/timm/models/levit.py @@ -931,6 +931,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1.linear', 'classifier': ('head.linear', 'head_dist.linear'), + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/mambaout.py b/timm/models/mambaout.py index 991781ad4b..97c821c3e2 100644 --- a/timm/models/mambaout.py +++ b/timm/models/mambaout.py @@ -557,6 +557,7 @@ def _cfg(url='', **kwargs): 'pool_size': (7, 7), 'crop_pct': 1.0, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/maxxvit.py b/timm/models/maxxvit.py index 7cd332f925..c6d2517537 100644 --- a/timm/models/maxxvit.py +++ b/timm/models/maxxvit.py @@ -2151,7 +2151,7 @@ def _cfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'mean': (0.5, 0.5, 0.5), 'std': (0.5, 0.5, 0.5), 'first_conv': 'stem.conv1', 'classifier': 'head.fc', 'fixed_input_size': True, - **kwargs + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/metaformer.py b/timm/models/metaformer.py index a157124694..c8e18d752f 100644 --- a/timm/models/metaformer.py +++ b/timm/models/metaformer.py @@ -801,6 +801,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 1.0, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'classifier': 'head.fc', 'first_conv': 'stem.conv', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/mlp_mixer.py b/timm/models/mlp_mixer.py index a6db3dd7bc..ed3120b978 100644 --- a/timm/models/mlp_mixer.py +++ b/timm/models/mlp_mixer.py @@ -592,6 +592,7 @@ def _cfg(url='', **kwargs) -> Dict[str, Any]: 'crop_pct': 0.875, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': (0.5, 0.5, 0.5), 'std': (0.5, 0.5, 0.5), 'first_conv': 'stem.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/mobilenetv3.py b/timm/models/mobilenetv3.py index 031cdbcf31..bfea64f127 100644 --- a/timm/models/mobilenetv3.py +++ b/timm/models/mobilenetv3.py @@ -1054,7 +1054,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv_stem', 'classifier': 'classifier', - **kwargs + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/mobilenetv5.py b/timm/models/mobilenetv5.py index f22dc76a3b..d1b2a52e21 100644 --- a/timm/models/mobilenetv5.py +++ b/timm/models/mobilenetv5.py @@ -842,7 +842,8 @@ def _cfg(url: str = '', **kwargs): hf_hub_id='timm/', mean=(0., 0., 0.), std=(1., 1., 1.), input_size=(3, 768, 768), - num_classes=0), + num_classes=0, + license='gemma'), # WIP classification configs for testing 'mobilenetv5_base.untrained': _cfg( diff --git a/timm/models/mobilevit.py b/timm/models/mobilevit.py index 93c9d4e306..d24afd66d3 100644 --- a/timm/models/mobilevit.py +++ b/timm/models/mobilevit.py @@ -595,6 +595,7 @@ def _cfg(url='', **kwargs): 'mean': (0., 0., 0.), 'std': (1., 1., 1.), 'first_conv': 'stem.conv', 'classifier': 'head.fc', 'fixed_input_size': False, + 'license': 'other', **kwargs } @@ -706,4 +707,4 @@ def mobilevitv2_200(pretrained=False, **kwargs) -> ByobNet: 'mobilevitv2_150_384_in22ft1k': 'mobilevitv2_150.cvnets_in22k_ft_in1k_384', 'mobilevitv2_175_384_in22ft1k': 'mobilevitv2_175.cvnets_in22k_ft_in1k_384', 'mobilevitv2_200_384_in22ft1k': 'mobilevitv2_200.cvnets_in22k_ft_in1k_384', -}) \ No newline at end of file +}) diff --git a/timm/models/mvitv2.py b/timm/models/mvitv2.py index 6b46e55970..45d8b9231f 100644 --- a/timm/models/mvitv2.py +++ b/timm/models/mvitv2.py @@ -1083,6 +1083,7 @@ def _cfg(url='', **kwargs): 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head.fc', 'fixed_input_size': True, + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/nasnet.py b/timm/models/nasnet.py index af17f44af4..c3b8d97ef5 100644 --- a/timm/models/nasnet.py +++ b/timm/models/nasnet.py @@ -705,6 +705,7 @@ def _create_nasnet(variant, pretrained=False, **kwargs): 'num_classes': 1000, 'first_conv': 'conv0.conv', 'classifier': 'last_linear', + 'license': 'apache-2.0', }, }) diff --git a/timm/models/nest.py b/timm/models/nest.py index 62aab6f023..41f9ebcc17 100644 --- a/timm/models/nest.py +++ b/timm/models/nest.py @@ -616,6 +616,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .875, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/nextvit.py b/timm/models/nextvit.py index fbaf4e515a..e7cbdca342 100644 --- a/timm/models/nextvit.py +++ b/timm/models/nextvit.py @@ -744,6 +744,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.95, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.0.conv', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/nfnet.py b/timm/models/nfnet.py index 16974d9fb3..e496a03515 100644 --- a/timm/models/nfnet.py +++ b/timm/models/nfnet.py @@ -839,7 +839,7 @@ def _dcfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.9, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, - 'first_conv': 'stem.conv1', 'classifier': 'head.fc', + 'first_conv': 'stem.conv1', 'classifier': 'head.fc', 'license': 'apache-2.0', **kwargs } @@ -1185,4 +1185,4 @@ def nf_ecaresnet101(pretrained: bool = False, **kwargs: Any) -> NormFreeNet: @register_model def test_nfnet(pretrained: bool = False, **kwargs: Any) -> NormFreeNet: """Test NFNet model for experimentation.""" - return _create_normfreenet('test_nfnet', pretrained=pretrained, **kwargs) \ No newline at end of file + return _create_normfreenet('test_nfnet', pretrained=pretrained, **kwargs) diff --git a/timm/models/pit.py b/timm/models/pit.py index dca27f598f..8d3743d13b 100644 --- a/timm/models/pit.py +++ b/timm/models/pit.py @@ -420,6 +420,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.conv', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/pnasnet.py b/timm/models/pnasnet.py index f8a16bd9e5..4d8cdd4e69 100644 --- a/timm/models/pnasnet.py +++ b/timm/models/pnasnet.py @@ -448,6 +448,7 @@ def _create_pnasnet(variant, pretrained=False, **kwargs): 'num_classes': 1000, 'first_conv': 'conv_0.conv', 'classifier': 'last_linear', + 'license': 'apache-2.0', }, }) diff --git a/timm/models/pvt_v2.py b/timm/models/pvt_v2.py index 1a00700022..95edfbcc02 100644 --- a/timm/models/pvt_v2.py +++ b/timm/models/pvt_v2.py @@ -532,6 +532,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.9, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head', 'fixed_input_size': False, + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/rdnet.py b/timm/models/rdnet.py index 2f86d93dcc..6c3e9ab536 100644 --- a/timm/models/rdnet.py +++ b/timm/models/rdnet.py @@ -480,6 +480,7 @@ def _cfg(url='', **kwargs): "paper_ids": "arXiv:2403.19588", "paper_name": "DenseNets Reloaded: Paradigm Shift Beyond ResNets and ViTs", "origin_url": "https://github.com/naver-ai/rdnet", + "license": "apache-2.0", **kwargs, } diff --git a/timm/models/regnet.py b/timm/models/regnet.py index b062eb2c2c..b868f1083c 100644 --- a/timm/models/regnet.py +++ b/timm/models/regnet.py @@ -1033,7 +1033,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'test_input_size': (3, 288, 288), 'crop_pct': 0.95, 'test_crop_pct': 1.0, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv', 'classifier': 'head.fc', - **kwargs + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/repghost.py b/timm/models/repghost.py index 779d27e037..47930ac1a9 100644 --- a/timm/models/repghost.py +++ b/timm/models/repghost.py @@ -487,6 +487,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv_stem', 'classifier': 'classifier', + 'license': 'mit', **kwargs } diff --git a/timm/models/repvit.py b/timm/models/repvit.py index 66294e5582..48800c52e0 100644 --- a/timm/models/repvit.py +++ b/timm/models/repvit.py @@ -558,6 +558,7 @@ def _cfg(url='', **kwargs): 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.conv1.c', 'classifier': ('head.head.l', 'head.head_dist.l'), + 'license': 'apache-2.0', **kwargs, } diff --git a/timm/models/res2net.py b/timm/models/res2net.py index 589bf2ddb2..28d15dc25a 100644 --- a/timm/models/res2net.py +++ b/timm/models/res2net.py @@ -139,6 +139,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv1', 'classifier': 'fc', + 'license': 'unknown', **kwargs } diff --git a/timm/models/resnest.py b/timm/models/resnest.py index 0695b38774..a4d3e7b73a 100644 --- a/timm/models/resnest.py +++ b/timm/models/resnest.py @@ -159,6 +159,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv1.0', 'classifier': 'fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/resnet.py b/timm/models/resnet.py index a92c5df6ce..41e7ce4588 100644 --- a/timm/models/resnet.py +++ b/timm/models/resnet.py @@ -799,6 +799,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv1', 'classifier': 'fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/resnetv2.py b/timm/models/resnetv2.py index 48c8131368..024aa8de50 100644 --- a/timm/models/resnetv2.py +++ b/timm/models/resnetv2.py @@ -899,6 +899,7 @@ def _cfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_INCEPTION_MEAN, 'std': IMAGENET_INCEPTION_STD, 'first_conv': 'stem.conv', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/selecsls.py b/timm/models/selecsls.py index 7937aeb73b..fe694938d1 100644 --- a/timm/models/selecsls.py +++ b/timm/models/selecsls.py @@ -351,6 +351,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.0', 'classifier': 'fc', + 'license': 'cc-by-4.0', **kwargs } diff --git a/timm/models/sequencer.py b/timm/models/sequencer.py index 1c3b21acae..180ea30c6d 100644 --- a/timm/models/sequencer.py +++ b/timm/models/sequencer.py @@ -508,6 +508,7 @@ def _cfg(url='', **kwargs): 'crop_pct': DEFAULT_CROP_PCT, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.proj', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/shvit.py b/timm/models/shvit.py index 396bc64d72..92f07f1c22 100644 --- a/timm/models/shvit.py +++ b/timm/models/shvit.py @@ -498,6 +498,7 @@ def _cfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.0.c', 'classifier': 'head.l', + 'license': 'mit', 'paper_ids': 'arXiv:2401.16456', 'paper_name': 'SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design', 'origin_url': 'https://github.com/ysj9909/SHViT', diff --git a/timm/models/sknet.py b/timm/models/sknet.py index 5884d20261..a5a4539211 100644 --- a/timm/models/sknet.py +++ b/timm/models/sknet.py @@ -185,6 +185,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv1', 'classifier': 'fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/starnet.py b/timm/models/starnet.py index 1cacd05cf9..e8560b6482 100644 --- a/timm/models/starnet.py +++ b/timm/models/starnet.py @@ -280,7 +280,7 @@ def _cfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'first_conv': 'stem.0.conv', 'classifier': 'head', 'paper_ids': 'arXiv:2403.19967', 'paper_name': 'Rewrite the Stars', - 'origin_url': 'https://github.com/ma-xu/Rewrite-the-Stars', + 'origin_url': 'https://github.com/ma-xu/Rewrite-the-Stars', 'license': 'apache-2.0', **kwargs } @@ -358,4 +358,4 @@ def starnet_s100(pretrained: bool = False, **kwargs: Any) -> StarNet: @register_model def starnet_s150(pretrained: bool = False, **kwargs: Any) -> StarNet: model_args = dict(base_dim=24, depths=[1, 2, 4, 2], mlp_ratio=3) - return _create_starnet('starnet_s150', pretrained=pretrained, **dict(model_args, **kwargs)) \ No newline at end of file + return _create_starnet('starnet_s150', pretrained=pretrained, **dict(model_args, **kwargs)) diff --git a/timm/models/swiftformer.py b/timm/models/swiftformer.py index 1a9900f1f0..245971d1e6 100644 --- a/timm/models/swiftformer.py +++ b/timm/models/swiftformer.py @@ -592,6 +592,7 @@ def _cfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'crop_pct': .95, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.0', 'classifier': ('head', 'head_dist'), + 'license': 'apache-2.0', 'paper_ids': 'arXiv:2303.15446', 'paper_name': 'SwiftFormer: Efficient Additive Attention for Transformer-based Real-time Mobile Vision Applications', 'origin_url': 'https://github.com/Amshaker/SwiftFormer', diff --git a/timm/models/swin_transformer_v2_cr.py b/timm/models/swin_transformer_v2_cr.py index 34aefbcebc..e99d81711d 100644 --- a/timm/models/swin_transformer_v2_cr.py +++ b/timm/models/swin_transformer_v2_cr.py @@ -1002,6 +1002,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs, } diff --git a/timm/models/tiny_vit.py b/timm/models/tiny_vit.py index a70d570f22..44a4b52be9 100644 --- a/timm/models/tiny_vit.py +++ b/timm/models/tiny_vit.py @@ -717,6 +717,7 @@ def _cfg(url='', **kwargs): 'pool_size': (7, 7), 'input_size': (3, 224, 224), 'crop_pct': 0.95, + 'license': 'apache-2.0', **kwargs, } diff --git a/timm/models/tnt.py b/timm/models/tnt.py index 85435aa465..2fee9356de 100644 --- a/timm/models/tnt.py +++ b/timm/models/tnt.py @@ -499,6 +499,7 @@ def _cfg(url='', **kwargs): 'paper_ids': 'arXiv:2103.00112', 'paper_name': 'Transformer in Transformer', 'origin_url': 'https://github.com/huawei-noah/Efficient-AI-Backbones/tree/master/tnt_pytorch', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/tresnet.py b/timm/models/tresnet.py index 7e318f6377..1dfb1c1b2e 100644 --- a/timm/models/tresnet.py +++ b/timm/models/tresnet.py @@ -389,6 +389,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': (0., 0., 0.), 'std': (1., 1., 1.), 'first_conv': 'body.conv1.conv', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/twins.py b/timm/models/twins.py index c27fd2be42..fa1a0a07ba 100644 --- a/timm/models/twins.py +++ b/timm/models/twins.py @@ -566,6 +566,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embeds.0.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/vgg.py b/timm/models/vgg.py index f51396cc2d..2545d9dc94 100644 --- a/timm/models/vgg.py +++ b/timm/models/vgg.py @@ -336,6 +336,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'features.0', 'classifier': 'head.fc', + 'license': 'bsd-3-clause', **kwargs } diff --git a/timm/models/visformer.py b/timm/models/visformer.py index 31f1015b6d..14ba70dcda 100644 --- a/timm/models/visformer.py +++ b/timm/models/visformer.py @@ -492,6 +492,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'stem.0', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/vision_transformer.py b/timm/models/vision_transformer.py index 376825f08f..1a31d8ddd5 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -1473,6 +1473,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'std': IMAGENET_INCEPTION_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs, } @@ -1870,17 +1871,21 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'vit_base_patch32_clip_224.laion400m_e32': _cfg( hf_hub_id='timm/', + license='mit', notes=('natively QuickGELU, use quickgelu model variant for original results',), mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, num_classes=512), 'vit_base_patch16_clip_224.laion400m_e32': _cfg( hf_hub_id='timm/', + license='mit', mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, crop_pct=1.0, num_classes=512), 'vit_base_patch16_plus_clip_240.laion400m_e32': _cfg( hf_hub_id='timm/', + license='mit', mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, input_size=(3, 240, 240), crop_pct=1.0, num_classes=640), 'vit_large_patch14_clip_224.laion400m_e32': _cfg( hf_hub_id='timm/', + license='mit', mean=OPENAI_CLIP_MEAN, std=OPENAI_CLIP_STD, crop_pct=1.0, num_classes=768), 'vit_base_patch32_clip_224.datacompxl': _cfg( @@ -2554,6 +2559,7 @@ def _cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'vit_intern300m_patch14_448.ogvl_dist': _cfg( hf_hub_id='timm/', + license='mit', mean=IMAGENET_DEFAULT_MEAN, std=IMAGENET_DEFAULT_STD, input_size=(3, 448, 448), crop_pct=1.0, num_classes=0, ), diff --git a/timm/models/vision_transformer_hybrid.py b/timm/models/vision_transformer_hybrid.py index b244c75589..c643e33a77 100644 --- a/timm/models/vision_transformer_hybrid.py +++ b/timm/models/vision_transformer_hybrid.py @@ -170,6 +170,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': (0.5, 0.5, 0.5), 'std': (0.5, 0.5, 0.5), 'first_conv': 'patch_embed.backbone.stem.conv', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } @@ -241,6 +242,7 @@ def _cfg(url='', **kwargs): 'vit_base_mci_224.apple_mclip_lt': _cfg( hf_hub_id='apple/mobileclip_b_lt_timm', url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_blt.pt', + license=None, num_classes=512, mean=(0., 0., 0.), std=(1., 1., 1.), first_conv='patch_embed.backbone.0.conv', ), diff --git a/timm/models/vision_transformer_relpos.py b/timm/models/vision_transformer_relpos.py index 492d6e2727..9fdcb887f4 100644 --- a/timm/models/vision_transformer_relpos.py +++ b/timm/models/vision_transformer_relpos.py @@ -537,6 +537,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_INCEPTION_MEAN, 'std': IMAGENET_INCEPTION_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head', + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/volo.py b/timm/models/volo.py index db231aeff8..205d0d432f 100644 --- a/timm/models/volo.py +++ b/timm/models/volo.py @@ -1247,6 +1247,7 @@ def _cfg(url: str = '', **kwargs: Any) -> Dict[str, Any]: 'crop_pct': .96, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.conv.0', 'classifier': ('head', 'aux_head'), + 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/vovnet.py b/timm/models/vovnet.py index ed8df58f23..4ed174a4f8 100644 --- a/timm/models/vovnet.py +++ b/timm/models/vovnet.py @@ -476,7 +476,8 @@ def _cfg(url='', **kwargs): 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, - 'first_conv': 'stem.0.conv', 'classifier': 'head.fc', **kwargs, + 'first_conv': 'stem.0.conv', 'classifier': 'head.fc', + 'license': 'apache-2.0', **kwargs, } diff --git a/timm/models/xception_aligned.py b/timm/models/xception_aligned.py index 18e1f0b4a9..1ad3bf8c39 100644 --- a/timm/models/xception_aligned.py +++ b/timm/models/xception_aligned.py @@ -358,7 +358,7 @@ def _cfg(url='', **kwargs): 'num_classes': 1000, 'input_size': (3, 299, 299), 'pool_size': (10, 10), 'crop_pct': 0.903, 'interpolation': 'bicubic', 'mean': IMAGENET_INCEPTION_MEAN, 'std': IMAGENET_INCEPTION_STD, - 'first_conv': 'stem.0.conv', 'classifier': 'head.fc', + 'first_conv': 'stem.0.conv', 'classifier': 'head.fc', 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/xcit.py b/timm/models/xcit.py index 7833a8e1ca..de3deefc95 100644 --- a/timm/models/xcit.py +++ b/timm/models/xcit.py @@ -691,7 +691,7 @@ def _cfg(url='', **kwargs): 'crop_pct': 1.0, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj.0.0', 'classifier': 'head', - **kwargs + 'license': 'apache-2.0', **kwargs } From c08ae1e724560308e7ff906e9da1745bd0bf19e8 Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Fri, 26 Sep 2025 19:43:31 +0200 Subject: [PATCH 8/9] Updating remaining licenses --- timm/models/_hub.py | 7 +++++++ timm/models/byobnet.py | 10 +++++----- timm/models/convnext.py | 8 ++++---- timm/models/eva.py | 4 ++-- timm/models/fastvit.py | 8 ++++---- timm/models/mobilevit.py | 2 +- timm/models/regnet.py | 16 ++++++++-------- timm/models/senet.py | 2 +- timm/models/vision_transformer_hybrid.py | 3 ++- timm/models/vitamin.py | 4 ++-- timm/models/xception.py | 3 ++- 11 files changed, 38 insertions(+), 29 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index c2b1ec823b..e4c603ff8c 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -578,4 +578,11 @@ def _get_license_from_hf_hub(model_id: str | None, hf_hub_id: str | None) -> str return None license = info.card_data.get("license").lower() if info.card_data else None + + if license == 'other': + name = info.card_data.get("license_name", None) + + if name is not None: + return name + return license diff --git a/timm/models/byobnet.py b/timm/models/byobnet.py index be722b46c6..0e33aabcfd 100644 --- a/timm/models/byobnet.py +++ b/timm/models/byobnet.py @@ -2606,31 +2606,31 @@ def _cfgr(url: str = '', **kwargs) -> Dict[str, Any]: hf_hub_id='timm/', crop_pct=0.875, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), - license='other', + license='mobileone-license', ), 'mobileone_s1.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), - license='other', + license='mobileone-license', ), 'mobileone_s2.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), - license='other', + license='mobileone-license', ), 'mobileone_s3.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), - license='other', + license='mobileone-license', ), 'mobileone_s4.apple_in1k': _cfg( hf_hub_id='timm/', crop_pct=0.9, first_conv=('stem.conv_kxk.0.conv', 'stem.conv_scale.conv'), - license='other', + license='mobileone-license', ), # original attention pool head variants diff --git a/timm/models/convnext.py b/timm/models/convnext.py index c62a488819..93d8ce769b 100644 --- a/timm/models/convnext.py +++ b/timm/models/convnext.py @@ -1113,25 +1113,25 @@ def _cfgv2(url='', **kwargs): hf_hub_id='timm/', crop_pct=1.0, num_classes=0, - license='dinov3', + license='dinov3-license', ), 'convnext_small.dinov3_lvd1689m': _cfg( hf_hub_id='timm/', crop_pct=1.0, num_classes=0, - license='dinov3', + license='dinov3-license', ), 'convnext_base.dinov3_lvd1689m': _cfg( hf_hub_id='timm/', crop_pct=1.0, num_classes=0, - license='dinov3', + license='dinov3-license', ), 'convnext_large.dinov3_lvd1689m': _cfg( hf_hub_id='timm/', crop_pct=1.0, num_classes=0, - license='dinov3', + license='dinov3-license', ), "test_convnext.r160_in1k": _cfg( diff --git a/timm/models/eva.py b/timm/models/eva.py index da5c97d144..761fee7644 100644 --- a/timm/models/eva.py +++ b/timm/models/eva.py @@ -1305,7 +1305,7 @@ def _dinov3_cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 1.0, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'patch_embed.proj', 'classifier': 'head', - 'license': 'dinov3', **kwargs + 'license': 'dinov3-license', **kwargs } default_cfgs = generate_default_cfgs({ @@ -2567,7 +2567,7 @@ def vit_large_patch16_rope_ape_224(pretrained: bool = False, **kwargs) -> Eva: rope_grid_indexing='xy', rope_temperature=100.0, ) - + model = _create_eva('vit_large_patch16_rope_ape_224', pretrained=pretrained, **dict(model_args, **kwargs)) return model diff --git a/timm/models/fastvit.py b/timm/models/fastvit.py index c0d39e6dbf..2b79e313df 100644 --- a/timm/models/fastvit.py +++ b/timm/models/fastvit.py @@ -1434,7 +1434,7 @@ def _cfg(url="", **kwargs): "license": "other", "std": IMAGENET_DEFAULT_STD, 'first_conv': ('stem.0.conv_kxk.0.conv', 'stem.0.conv_scale.conv'), - "classifier": "head.fc", + "classifier": "head.fc", "license": "fastvit-license", **kwargs, } @@ -1482,21 +1482,21 @@ def _cfg(url="", **kwargs): url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_s0.pt', crop_pct=0.95, num_classes=512, # CLIP proj dim - mean=(0., 0., 0.), std=(1., 1., 1.), license=None, + mean=(0., 0., 0.), std=(1., 1., 1.), license='apple-amlr' ), "fastvit_mci1.apple_mclip": _cfg( hf_hub_id='apple/mobileclip_s1_timm', url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_s1.pt', crop_pct=0.95, num_classes=512, # CLIP proj dim - mean=(0., 0., 0.), std=(1., 1., 1.), license=None, + mean=(0., 0., 0.), std=(1., 1., 1.), license='apple-amlr' ), "fastvit_mci2.apple_mclip": _cfg( hf_hub_id='apple/mobileclip_s2_timm', url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_s2.pt', crop_pct=0.95, num_classes=512, # CLIP proj dim - mean=(0., 0., 0.), std=(1., 1., 1.), license=None, + mean=(0., 0., 0.), std=(1., 1., 1.), license='apple-amlr' ), "fastvit_mci0.apple_mclip2_dfndr2b": _cfg( diff --git a/timm/models/mobilevit.py b/timm/models/mobilevit.py index d24afd66d3..2e68b4df2c 100644 --- a/timm/models/mobilevit.py +++ b/timm/models/mobilevit.py @@ -595,7 +595,7 @@ def _cfg(url='', **kwargs): 'mean': (0., 0., 0.), 'std': (1., 1., 1.), 'first_conv': 'stem.conv', 'classifier': 'head.fc', 'fixed_input_size': False, - 'license': 'other', + 'license': 'cvnets-license', **kwargs } diff --git a/timm/models/regnet.py b/timm/models/regnet.py index b868f1083c..9b79d8fc80 100644 --- a/timm/models/regnet.py +++ b/timm/models/regnet.py @@ -1195,37 +1195,37 @@ def _cfgtv2(url: str = '', **kwargs) -> Dict[str, Any]: 'regnety_320.seer_ft_in1k': _cfgtv2( hf_hub_id='timm/', - license='other', origin_url='https://github.com/facebookresearch/vissl', + license='seer-license', origin_url='https://github.com/facebookresearch/vissl', url='https://dl.fbaipublicfiles.com/vissl/model_zoo/seer_finetuned/seer_regnet32_finetuned_in1k_model_final_checkpoint_phase78.torch', input_size=(3, 384, 384), pool_size=(12, 12), crop_pct=1.0), 'regnety_640.seer_ft_in1k': _cfgtv2( hf_hub_id='timm/', - license='other', origin_url='https://github.com/facebookresearch/vissl', + license='seer-license', origin_url='https://github.com/facebookresearch/vissl', url='https://dl.fbaipublicfiles.com/vissl/model_zoo/seer_finetuned/seer_regnet64_finetuned_in1k_model_final_checkpoint_phase78.torch', input_size=(3, 384, 384), pool_size=(12, 12), crop_pct=1.0), 'regnety_1280.seer_ft_in1k': _cfgtv2( hf_hub_id='timm/', - license='other', origin_url='https://github.com/facebookresearch/vissl', + license='seer-license', origin_url='https://github.com/facebookresearch/vissl', url='https://dl.fbaipublicfiles.com/vissl/model_zoo/seer_finetuned/seer_regnet128_finetuned_in1k_model_final_checkpoint_phase78.torch', input_size=(3, 384, 384), pool_size=(12, 12), crop_pct=1.0), 'regnety_2560.seer_ft_in1k': _cfgtv2( hf_hub_id='timm/', - license='other', origin_url='https://github.com/facebookresearch/vissl', + license='seer-license', origin_url='https://github.com/facebookresearch/vissl', url='https://dl.fbaipublicfiles.com/vissl/model_zoo/seer_finetuned/seer_regnet256_finetuned_in1k_model_final_checkpoint_phase38.torch', input_size=(3, 384, 384), pool_size=(12, 12), crop_pct=1.0), 'regnety_320.seer': _cfgtv2( hf_hub_id='timm/', url='https://dl.fbaipublicfiles.com/vissl/model_zoo/seer_regnet32d/seer_regnet32gf_model_iteration244000.torch', - num_classes=0, license='other', origin_url='https://github.com/facebookresearch/vissl'), + num_classes=0, license='seer-license', origin_url='https://github.com/facebookresearch/vissl'), 'regnety_640.seer': _cfgtv2( hf_hub_id='timm/', url='https://dl.fbaipublicfiles.com/vissl/model_zoo/seer_regnet64/seer_regnet64gf_model_final_checkpoint_phase0.torch', - num_classes=0, license='other', origin_url='https://github.com/facebookresearch/vissl'), + num_classes=0, license='seer-license', origin_url='https://github.com/facebookresearch/vissl'), 'regnety_1280.seer': _cfgtv2( hf_hub_id='timm/', url='https://dl.fbaipublicfiles.com/vissl/model_zoo/swav_ig1b_regnet128Gf_cnstant_bs32_node16_sinkhorn10_proto16k_syncBN64_warmup8k/model_final_checkpoint_phase0.torch', - num_classes=0, license='other', origin_url='https://github.com/facebookresearch/vissl'), + num_classes=0, license='seer-license', origin_url='https://github.com/facebookresearch/vissl'), # FIXME invalid weight <-> model match, mistake on their end #'regnety_2560.seer': _cfgtv2( # url='https://dl.fbaipublicfiles.com/vissl/model_zoo/swav_ig1b_cosine_rg256gf_noBNhead_wd1e5_fairstore_bs16_node64_sinkhorn10_proto16k_apex_syncBN64_warmup8k/model_final_checkpoint_phase0.torch', @@ -1486,4 +1486,4 @@ def regnetz_040_h(pretrained: bool = False, **kwargs) -> RegNet: register_model_deprecations(__name__, { 'regnetz_040h': 'regnetz_040_h', -}) \ No newline at end of file +}) diff --git a/timm/models/senet.py b/timm/models/senet.py index 6a1bc99eb2..f317307d34 100644 --- a/timm/models/senet.py +++ b/timm/models/senet.py @@ -448,7 +448,7 @@ def _cfg(url='', **kwargs): 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bilinear', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, - 'first_conv': 'layer0.conv1', 'classifier': 'last_linear', + 'first_conv': 'layer0.conv1', 'classifier': 'last_linear', 'license': 'apache-2.0', **kwargs } diff --git a/timm/models/vision_transformer_hybrid.py b/timm/models/vision_transformer_hybrid.py index c643e33a77..eb255f1bd6 100644 --- a/timm/models/vision_transformer_hybrid.py +++ b/timm/models/vision_transformer_hybrid.py @@ -242,7 +242,7 @@ def _cfg(url='', **kwargs): 'vit_base_mci_224.apple_mclip_lt': _cfg( hf_hub_id='apple/mobileclip_b_lt_timm', url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_blt.pt', - license=None, + license='apple-amlr', num_classes=512, mean=(0., 0., 0.), std=(1., 1., 1.), first_conv='patch_embed.backbone.0.conv', ), @@ -250,6 +250,7 @@ def _cfg(url='', **kwargs): hf_hub_id='apple/mobileclip_b_timm', url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileclip/mobileclip_b.pt', num_classes=512, + license='apple-amlr', mean=(0., 0., 0.), std=(1., 1., 1.), first_conv='patch_embed.backbone.0.conv', ), 'vit_base_mci_224.apple_mclip2_dfndr2b': _cfg( diff --git a/timm/models/vitamin.py b/timm/models/vitamin.py index 5fc1556a96..56882b6a43 100644 --- a/timm/models/vitamin.py +++ b/timm/models/vitamin.py @@ -325,7 +325,7 @@ def _cfg(url='', **kwargs): 'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True, 'mean': OPENAI_CLIP_MEAN, 'std': OPENAI_CLIP_STD, 'first_conv': 'patch_embed.backbone.stem.conv1', - 'classifier': 'head', + 'classifier': 'head', 'license': 'mit', **kwargs } @@ -623,4 +623,4 @@ def vitamin_xlarge_384(pretrained=False, **kwargs) -> VisionTransformer: img_size=384, embed_dim=1152, depth=32, num_heads=16, mlp_layer=GeGluMlp, mlp_ratio=2., class_token=False, global_pool='avg', pos_embed='none', embed_cfg=embed_cfg) model = _create_vitamin('vitamin_xlarge_384', pretrained=pretrained, **dict(model_args, **kwargs)) - return model \ No newline at end of file + return model diff --git a/timm/models/xception.py b/timm/models/xception.py index 6f0b5dc590..d8edfeb17d 100644 --- a/timm/models/xception.py +++ b/timm/models/xception.py @@ -280,7 +280,8 @@ def _xception(variant, pretrained=False, **kwargs): 'std': (0.5, 0.5, 0.5), 'num_classes': 1000, 'first_conv': 'conv1', - 'classifier': 'fc' + 'classifier': 'fc', + 'license': 'apache-2.0', # The resize parameter of the validation transform should be 333, and make sure to center crop at 299x299 } }) From 251c1caa51da80e65d5fdfa99cbbd0aca2ba4582 Mon Sep 17 00:00:00 2001 From: Alexander Dann Date: Fri, 26 Sep 2025 19:48:00 +0200 Subject: [PATCH 9/9] Reusing license field --- timm/models/fastvit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timm/models/fastvit.py b/timm/models/fastvit.py index 2b79e313df..61dbd04c49 100644 --- a/timm/models/fastvit.py +++ b/timm/models/fastvit.py @@ -1431,10 +1431,10 @@ def _cfg(url="", **kwargs): "crop_pct": 0.9, "interpolation": "bicubic", "mean": IMAGENET_DEFAULT_MEAN, - "license": "other", + "license": "fastvit-license", "std": IMAGENET_DEFAULT_STD, 'first_conv': ('stem.0.conv_kxk.0.conv', 'stem.0.conv_scale.conv'), - "classifier": "head.fc", "license": "fastvit-license", + "classifier": "head.fc", **kwargs, }