From ae9bb389d90e372e9a103d0f94879a949675133e 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 c77b04d854..ad2b0e375e 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -32,9 +32,9 @@ try: from huggingface_hub import ( create_repo, get_hf_file_metadata, - hf_hub_download, hf_hub_url, + hf_hub_download, hf_hub_url, model_info, repo_type_and_id_from_hf_id, upload_folder) - from huggingface_hub.utils import EntryNotFoundError + 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: @@ -540,3 +540,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 81d11a0654..c5ecf4f3ec 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, 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 @@ -918,22 +919,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(), @@ -941,48 +945,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), @@ -990,10 +1004,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), }) @@ -1111,4 +1127,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 ed00d06c8cd9c430a5e0f112004fc2cdcd08976a 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 | 139 ++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 63 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index ad2b0e375e..7d9e64d791 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 @@ -31,10 +32,16 @@ try: from huggingface_hub import ( - create_repo, get_hf_file_metadata, - hf_hub_download, hf_hub_url, model_info, - repo_type_and_id_from_hf_id, upload_folder) + create_repo, + get_hf_file_metadata, + hf_hub_download, + hf_hub_url, + model_info, + repo_type_and_id_from_hf_id, + upload_folder, + ) 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: @@ -43,8 +50,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 @@ -69,10 +84,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 @@ -95,9 +110,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 @@ -114,7 +129,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 @@ -124,7 +139,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 @@ -144,9 +160,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( @@ -158,8 +174,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 @@ -170,7 +186,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"] @@ -190,8 +206,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) @@ -201,7 +217,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) @@ -214,10 +230,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) @@ -234,7 +250,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 @@ -266,9 +283,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: @@ -283,10 +301,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: @@ -300,10 +315,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) @@ -317,10 +332,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 = {} @@ -339,7 +351,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) @@ -366,11 +379,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) @@ -394,18 +407,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: @@ -459,9 +472,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 09a13d8b05aa2a46fd7b396a089ad871c8321ba1 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 | 139 ++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 76 deletions(-) diff --git a/timm/models/_hub.py b/timm/models/_hub.py index 7d9e64d791..ad2b0e375e 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 @@ -32,16 +31,10 @@ try: from huggingface_hub import ( - create_repo, - get_hf_file_metadata, - hf_hub_download, - hf_hub_url, - model_info, - repo_type_and_id_from_hf_id, - upload_folder, - ) + create_repo, get_hf_file_metadata, + hf_hub_download, hf_hub_url, model_info, + repo_type_and_id_from_hf_id, upload_folder) 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: @@ -50,16 +43,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 @@ -84,10 +69,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 @@ -110,9 +95,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 @@ -129,7 +114,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 @@ -139,8 +124,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 @@ -160,9 +144,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( @@ -174,8 +158,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 @@ -186,7 +170,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"] @@ -206,8 +190,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) @@ -217,7 +201,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) @@ -230,10 +214,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) @@ -250,8 +234,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 @@ -283,10 +266,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: @@ -301,7 +283,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: @@ -315,10 +300,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) @@ -332,7 +317,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 = {} @@ -351,8 +339,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) @@ -379,11 +366,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) @@ -407,18 +394,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: @@ -472,9 +459,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 a955d2cec9fe11c4413415b70a5fbfd4eb3c7498 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 c5ecf4f3ec..81d11a0654 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, 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 @@ -919,25 +918,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(), @@ -945,58 +941,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), @@ -1004,12 +990,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), }) @@ -1127,4 +1111,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 166a524850b84e4731b810d02862c3d059299e51 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 ad2b0e375e..9b581e2397 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -542,17 +542,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. @@ -566,17 +566,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 24b67f8a5335f57cfd50b207722cf351a2a3b208 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 9b581e2397..ad2b0e375e 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -542,17 +542,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. @@ -566,17 +566,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 60f2837486ccb1ce42f30f6fe0bdf2ec29e4bd51 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 ad2b0e375e..c88124e023 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -575,8 +575,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 5b5973801d..78c2c85efd 100644 --- a/timm/models/beit.py +++ b/timm/models/beit.py @@ -738,6 +738,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 e37d25b6ef..b007f71126 100644 --- a/timm/models/byobnet.py +++ b/timm/models/byobnet.py @@ -2279,6 +2279,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 } @@ -2298,6 +2299,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 } @@ -2451,26 +2453,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 @@ -2479,48 +2486,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 @@ -2528,41 +2543,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 2c500ec3dd..bb28dfe574 100644 --- a/timm/models/cait.py +++ b/timm/models/cait.py @@ -472,6 +472,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 e0b0bcfb84..aaf0a90a52 100644 --- a/timm/models/coat.py +++ b/timm/models/coat.py @@ -720,6 +720,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 } @@ -800,4 +801,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 cbe3b51ece..262b2a82a6 100644 --- a/timm/models/convit.py +++ b/timm/models/convit.py @@ -391,7 +391,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 de986e3baf..f13300ff22 100644 --- a/timm/models/convmixer.py +++ b/timm/models/convmixer.py @@ -115,7 +115,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 } @@ -143,4 +143,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 cdc34eba2f..eecea1013a 100644 --- a/timm/models/convnext.py +++ b/timm/models/convnext.py @@ -665,7 +665,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 0e1de2fadd..bacc9ba068 100644 --- a/timm/models/crossvit.py +++ b/timm/models/crossvit.py @@ -489,6 +489,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 81d11a0654..7c8ac71dcf 100644 --- a/timm/models/cspnet.py +++ b/timm/models/cspnet.py @@ -917,7 +917,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 } @@ -1111,4 +1111,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 22b4a1a05f..ae7c8880df 100644 --- a/timm/models/davit.py +++ b/timm/models/davit.py @@ -806,6 +806,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 0072013bf6..b1e0ae918f 100644 --- a/timm/models/deit.py +++ b/timm/models/deit.py @@ -140,6 +140,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 1a9f9887a5..0c14b9f42e 100644 --- a/timm/models/densenet.py +++ b/timm/models/densenet.py @@ -472,7 +472,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 197060e4e6..465644e149 100644 --- a/timm/models/dla.py +++ b/timm/models/dla.py @@ -399,7 +399,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 } @@ -415,8 +415,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 c03e5fe1a1..87a851e594 100644 --- a/timm/models/dpn.py +++ b/timm/models/dpn.py @@ -295,7 +295,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 333f73f0d5..18de7c22f0 100644 --- a/timm/models/edgenext.py +++ b/timm/models/edgenext.py @@ -560,6 +560,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 669062d365..a1a9064e16 100644 --- a/timm/models/efficientformer.py +++ b/timm/models/efficientformer.py @@ -590,6 +590,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 39c832c8c2..3e51aa2f67 100644 --- a/timm/models/efficientformer_v2.py +++ b/timm/models/efficientformer_v2.py @@ -726,6 +726,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 d1976944da..08a0dbad95 100644 --- a/timm/models/efficientnet.py +++ b/timm/models/efficientnet.py @@ -1312,7 +1312,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 8b35a04c87..f46eb0763b 100644 --- a/timm/models/efficientvit_mit.py +++ b/timm/models/efficientvit_mit.py @@ -998,6 +998,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 80c5d99995..4f3b7e3bed 100644 --- a/timm/models/efficientvit_msra.py +++ b/timm/models/efficientvit_msra.py @@ -598,6 +598,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 1cd690b06c..300316e99c 100644 --- a/timm/models/eva.py +++ b/timm/models/eva.py @@ -1256,7 +1256,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 b9e4aed249..07c1a00d9e 100644 --- a/timm/models/fasternet.py +++ b/timm/models/fasternet.py @@ -405,6 +405,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 9939095c43..8117d107b6 100644 --- a/timm/models/fastvit.py +++ b/timm/models/fastvit.py @@ -1360,6 +1360,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", @@ -1410,21 +1411,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( @@ -1732,4 +1733,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 367e5dfff5..ad85f93be0 100644 --- a/timm/models/gcvit.py +++ b/timm/models/gcvit.py @@ -582,6 +582,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 126d638f43..02fb224a93 100644 --- a/timm/models/ghostnet.py +++ b/timm/models/ghostnet.py @@ -850,6 +850,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 5c49f9ddca..0e772800d1 100644 --- a/timm/models/hgnet.py +++ b/timm/models/hgnet.py @@ -694,6 +694,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 fa9d6d2833..fe335fd710 100644 --- a/timm/models/hiera.py +++ b/timm/models/hiera.py @@ -818,6 +818,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 cd8bc6c8e9..a3dfdafad8 100644 --- a/timm/models/hieradet_sam2.py +++ b/timm/models/hieradet_sam2.py @@ -532,6 +532,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 92ee3511cf..0e54559f14 100644 --- a/timm/models/hrnet.py +++ b/timm/models/hrnet.py @@ -888,14 +888,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 3159ac03be..9405c40f43 100644 --- a/timm/models/inception_next.py +++ b/timm/models/inception_next.py @@ -427,6 +427,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 d691be7a8f..2f4b91e324 100644 --- a/timm/models/inception_resnet_v2.py +++ b/timm/models/inception_resnet_v2.py @@ -317,6 +317,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 @@ -326,6 +327,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 a55521c3de..10b37dfaff 100644 --- a/timm/models/inception_v3.py +++ b/timm/models/inception_v3.py @@ -418,7 +418,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 } @@ -454,4 +454,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 cadbf95284..472052e398 100644 --- a/timm/models/inception_v4.py +++ b/timm/models/inception_v4.py @@ -378,6 +378,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 a4c9ce628a..7981765c92 100644 --- a/timm/models/levit.py +++ b/timm/models/levit.py @@ -842,6 +842,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 b28827ed71..5e838cf3a1 100644 --- a/timm/models/mambaout.py +++ b/timm/models/mambaout.py @@ -526,6 +526,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 85cc3b4238..c58de60063 100644 --- a/timm/models/maxxvit.py +++ b/timm/models/maxxvit.py @@ -2079,7 +2079,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 3364a79563..efbaa6e4d4 100644 --- a/timm/models/metaformer.py +++ b/timm/models/metaformer.py @@ -740,6 +740,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 838e0e0117..cb76f17284 100644 --- a/timm/models/mlp_mixer.py +++ b/timm/models/mlp_mixer.py @@ -560,6 +560,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 eb87bb38d8..0c2969099c 100644 --- a/timm/models/mobilenetv3.py +++ b/timm/models/mobilenetv3.py @@ -1032,7 +1032,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 8a3e132d1e..9a0e2ec93d 100644 --- a/timm/models/mobilenetv5.py +++ b/timm/models/mobilenetv5.py @@ -826,7 +826,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 9c84871e6d..9f2aa9cbe2 100644 --- a/timm/models/mobilevit.py +++ b/timm/models/mobilevit.py @@ -567,6 +567,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 } @@ -678,4 +679,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 01c4550ed8..7e08655e27 100644 --- a/timm/models/mvitv2.py +++ b/timm/models/mvitv2.py @@ -1051,6 +1051,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 8edee45c86..040d72f1e6 100644 --- a/timm/models/nasnet.py +++ b/timm/models/nasnet.py @@ -586,6 +586,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 9a423a9776..2555154a85 100644 --- a/timm/models/nest.py +++ b/timm/models/nest.py @@ -571,6 +571,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 402a9d76ea..70629bb4b0 100644 --- a/timm/models/nextvit.py +++ b/timm/models/nextvit.py @@ -683,6 +683,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 68b8b1b6d6..93814995c4 100644 --- a/timm/models/nfnet.py +++ b/timm/models/nfnet.py @@ -824,7 +824,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 } @@ -1170,4 +1170,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 b7985cf998..04b24ca09e 100644 --- a/timm/models/pit.py +++ b/timm/models/pit.py @@ -393,6 +393,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 7f33aaeabb..51faba8b72 100644 --- a/timm/models/pnasnet.py +++ b/timm/models/pnasnet.py @@ -363,6 +363,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 0259a1f64e..d242ce8b7a 100644 --- a/timm/models/pvt_v2.py +++ b/timm/models/pvt_v2.py @@ -500,6 +500,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 5764b6ed82..81bfa3b25f 100644 --- a/timm/models/rdnet.py +++ b/timm/models/rdnet.py @@ -434,6 +434,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 f05bad37ba..d5b9ee5ecb 100644 --- a/timm/models/regnet.py +++ b/timm/models/regnet.py @@ -1011,7 +1011,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 c5a7d93a4f..64facda4c8 100644 --- a/timm/models/repghost.py +++ b/timm/models/repghost.py @@ -456,6 +456,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 3641d6f70c..f071e4b26f 100644 --- a/timm/models/repvit.py +++ b/timm/models/repvit.py @@ -440,6 +440,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 691f929b91..d55647410b 100644 --- a/timm/models/res2net.py +++ b/timm/models/res2net.py @@ -127,6 +127,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 5b1438017e..3b4eff64b3 100644 --- a/timm/models/resnest.py +++ b/timm/models/resnest.py @@ -133,6 +133,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 ca07682b80..6add0a846e 100644 --- a/timm/models/resnet.py +++ b/timm/models/resnet.py @@ -748,6 +748,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 0b78e7b44d..efb1595947 100644 --- a/timm/models/resnetv2.py +++ b/timm/models/resnetv2.py @@ -872,6 +872,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 dc19ff41d1..e49851473a 100644 --- a/timm/models/selecsls.py +++ b/timm/models/selecsls.py @@ -321,6 +321,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 86c4b1df4d..94da5cf002 100644 --- a/timm/models/sequencer.py +++ b/timm/models/sequencer.py @@ -478,6 +478,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 c165f1a280..9bfd15014e 100644 --- a/timm/models/shvit.py +++ b/timm/models/shvit.py @@ -463,6 +463,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 b12df2319f..d305183691 100644 --- a/timm/models/sknet.py +++ b/timm/models/sknet.py @@ -157,6 +157,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 9ed32a85d7..7d6b55a001 100644 --- a/timm/models/starnet.py +++ b/timm/models/starnet.py @@ -267,7 +267,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 } @@ -345,4 +345,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 38df6f1638..2323dae392 100644 --- a/timm/models/swiftformer.py +++ b/timm/models/swiftformer.py @@ -555,6 +555,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 1ef3164fd9..f3a2aa22f8 100644 --- a/timm/models/swin_transformer_v2_cr.py +++ b/timm/models/swin_transformer_v2_cr.py @@ -962,6 +962,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 39bacc850c..1891d85499 100644 --- a/timm/models/tiny_vit.py +++ b/timm/models/tiny_vit.py @@ -640,6 +640,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 0ecd8e72a4..01e07446ed 100644 --- a/timm/models/tnt.py +++ b/timm/models/tnt.py @@ -471,6 +471,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 2c452e4707..ece735df20 100644 --- a/timm/models/tresnet.py +++ b/timm/models/tresnet.py @@ -353,6 +353,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 74d22e24c1..d138b7c624 100644 --- a/timm/models/twins.py +++ b/timm/models/twins.py @@ -519,6 +519,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 23c8834894..0085a2b439 100644 --- a/timm/models/vgg.py +++ b/timm/models/vgg.py @@ -328,6 +328,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 2ed3be5da8..0392f73a98 100644 --- a/timm/models/visformer.py +++ b/timm/models/visformer.py @@ -452,6 +452,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 1c21d4ffb2..70dd41d5ac 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -1474,6 +1474,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, } @@ -1869,17 +1870,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( @@ -2553,6 +2558,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 7290bb7697..1f0b55f143 100644 --- a/timm/models/vision_transformer_hybrid.py +++ b/timm/models/vision_transformer_hybrid.py @@ -150,6 +150,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 } @@ -221,6 +222,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 dcccba73ba..70a5c7f0d6 100644 --- a/timm/models/vision_transformer_relpos.py +++ b/timm/models/vision_transformer_relpos.py @@ -516,6 +516,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 f417dc6df1..ab70c3f77b 100644 --- a/timm/models/volo.py +++ b/timm/models/volo.py @@ -1189,6 +1189,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 8da9431f09..eb1081fb54 100644 --- a/timm/models/vovnet.py +++ b/timm/models/vovnet.py @@ -466,7 +466,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 3c67fa8036..77a405d7b6 100644 --- a/timm/models/xception_aligned.py +++ b/timm/models/xception_aligned.py @@ -312,7 +312,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 271578adf8..794451dc25 100644 --- a/timm/models/xcit.py +++ b/timm/models/xcit.py @@ -612,7 +612,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 b6be04652c49a1406e1bdd04e07e16ab3c423b9e 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 c88124e023..22a6487676 100644 --- a/timm/models/_hub.py +++ b/timm/models/_hub.py @@ -585,4 +585,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 b007f71126..26ec77ade9 100644 --- a/timm/models/byobnet.py +++ b/timm/models/byobnet.py @@ -2453,31 +2453,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 eecea1013a..a8f193baee 100644 --- a/timm/models/convnext.py +++ b/timm/models/convnext.py @@ -1067,25 +1067,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 300316e99c..58aecf6765 100644 --- a/timm/models/eva.py +++ b/timm/models/eva.py @@ -1276,7 +1276,7 @@ def _dinov3_cfg(url: str = '', **kwargs) -> Dict[str, Any]: 'crop_pct': 1.0, 'interpolation': 'bicubic', 'min_input_size': (3, 128, 128), '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({ @@ -2538,7 +2538,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 8117d107b6..2618ccdb7f 100644 --- a/timm/models/fastvit.py +++ b/timm/models/fastvit.py @@ -1363,7 +1363,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, } @@ -1411,21 +1411,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 9f2aa9cbe2..f16b35bd80 100644 --- a/timm/models/mobilevit.py +++ b/timm/models/mobilevit.py @@ -567,7 +567,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 d5b9ee5ecb..ed82c8dfa7 100644 --- a/timm/models/regnet.py +++ b/timm/models/regnet.py @@ -1173,37 +1173,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', @@ -1464,4 +1464,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 9884c61419..e9a48db1f8 100644 --- a/timm/models/senet.py +++ b/timm/models/senet.py @@ -372,7 +372,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 1f0b55f143..525c38cee0 100644 --- a/timm/models/vision_transformer_hybrid.py +++ b/timm/models/vision_transformer_hybrid.py @@ -222,7 +222,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', ), @@ -230,6 +230,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 fa76275426..ed4f67d107 100644 --- a/timm/models/vitamin.py +++ b/timm/models/vitamin.py @@ -303,7 +303,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 } @@ -601,4 +601,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 e1f92abfa0..f64e9e4dd1 100644 --- a/timm/models/xception.py +++ b/timm/models/xception.py @@ -239,7 +239,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 c09d5fedba48af08e600cc54a26fb4e8023ea1c0 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 2618ccdb7f..de4c67b21b 100644 --- a/timm/models/fastvit.py +++ b/timm/models/fastvit.py @@ -1360,10 +1360,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, }